File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,12 @@ def init_distributed_device_so(
127127 global_rank = 0
128128 local_rank = 0
129129 device_type , * device_idx = device .split (':' , maxsplit = 1 )
130+ is_avail , is_known = is_device_available (device_type )
131+ if not is_known :
132+ warnings .warn (f"Device { device } was not known and checked for availability, trying anyways." )
133+ elif not is_avail :
134+ warnings .warn (f"Device { device } was not available, falling back to CPU." )
135+ device_type = device = 'cpu'
130136
131137 if horovod :
132138 import horovod .torch as hvd
@@ -172,13 +178,6 @@ def init_distributed_device_so(
172178 global_rank = torch .distributed .get_rank ()
173179 distributed = True
174180
175- is_avail , is_known = is_device_available (device_type )
176- if not is_known :
177- warnings .warn (f"Device { device } was not known and checked for availability, trying anyways." )
178- elif not is_avail :
179- warnings .warn (f"Device { device } was not available, falling back to CPU." )
180- device_type = device = 'cpu'
181-
182181 if distributed and not no_set_device_rank and device_type not in ('cpu' , 'mps' ):
183182 # Ignore manually specified device index in distributed mode and
184183 # override with resolved local rank, fewer headaches in most setups.
You can’t perform that action at this time.
0 commit comments