mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-04 05:10:06 +06:00
guard torch distributed check (#39057)
* guard torch distributed check * Update src/transformers/pipelines/base.py --------- Co-authored-by: Matt <Rocketknight1@users.noreply.github.com>
This commit is contained in:
parent
49d9fd49bd
commit
c8764ab935
@ -1033,7 +1033,7 @@ class Pipeline(_ScikitCompat, PushToHubMixin):
|
|||||||
else:
|
else:
|
||||||
self.device = device if device is not None else -1
|
self.device = device if device is not None else -1
|
||||||
|
|
||||||
if is_torch_available() and torch.distributed.is_initialized():
|
if is_torch_available() and torch.distributed.is_available() and torch.distributed.is_initialized():
|
||||||
self.device = self.model.device
|
self.device = self.model.device
|
||||||
logger.warning(f"Device set to use {self.device}")
|
logger.warning(f"Device set to use {self.device}")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user