6868 numpy_to_pil ,
6969)
7070from ..utils .hub_utils import _check_legacy_sharding_variant_format , load_or_create_model_card , populate_model_card
71- from ..utils .torch_utils import empty_device_cache , get_device , is_compiled_module
71+ from ..utils .torch_utils import empty_device_cache , get_device , is_compiled_module , is_torch_dist_rank_zero
7272
7373
7474if is_torch_npu_available ():
@@ -983,7 +983,7 @@ def load_module(name, value):
983983 current_device_map = None
984984 _maybe_warn_for_wrong_component_in_quant_config (init_dict , quantization_config )
985985 logging_tqdm_kwargs = {"desc" : "Loading pipeline components..." }
986- if cls . _progress_bar_disabled_for_rank ():
986+ if not is_torch_dist_rank_zero ():
987987 logging_tqdm_kwargs ["disable" ] = True
988988
989989 for name , (library_name , class_name ) in logging .tqdm (init_dict .items (), ** logging_tqdm_kwargs ):
@@ -1914,7 +1914,7 @@ def progress_bar(self, iterable=None, total=None):
19141914
19151915 progress_bar_config = dict (self ._progress_bar_config )
19161916 if "disable" not in progress_bar_config :
1917- progress_bar_config ["disable" ] = self . _progress_bar_disabled_for_rank ()
1917+ progress_bar_config ["disable" ] = not is_torch_dist_rank_zero ()
19181918
19191919 if iterable is not None :
19201920 return tqdm (iterable , ** progress_bar_config )
@@ -1926,15 +1926,6 @@ def progress_bar(self, iterable=None, total=None):
19261926 def set_progress_bar_config (self , ** kwargs ):
19271927 self ._progress_bar_config = kwargs
19281928
1929- @staticmethod
1930- def _progress_bar_disabled_for_rank ():
1931- if torch .distributed .is_available () and torch .distributed .is_initialized ():
1932- try :
1933- return torch .distributed .get_rank () != 0
1934- except (RuntimeError , ValueError ):
1935- return False
1936- return False
1937-
19381929 def enable_xformers_memory_efficient_attention (self , attention_op : Optional [Callable ] = None ):
19391930 r"""
19401931 Enable memory efficient attention from [xFormers](https://facebookresearch.github.io/xformers/). When this
0 commit comments