mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
Make sure torch_is_available before using torch.distributed (#37693)
fix
This commit is contained in:
parent
864e9636ff
commit
02baa61fab
@ -997,7 +997,7 @@ class Pipeline(_ScikitCompat, PushToHubMixin):
|
||||
else:
|
||||
self.device = device if device is not None else -1
|
||||
|
||||
if torch.distributed.is_initialized():
|
||||
if is_torch_available() and torch.distributed.is_initialized():
|
||||
self.device = self.model.device
|
||||
logger.warning(f"Device set to use {self.device}")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user