[XPU] Use spawn with XPU multiprocessing (#20649)
Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
This commit is contained in:
@@ -1535,6 +1535,13 @@ def cuda_is_initialized() -> bool:
|
||||
return torch.cuda.is_initialized()
|
||||
|
||||
|
||||
def xpu_is_initialized() -> bool:
|
||||
"""Check if XPU is initialized."""
|
||||
if not torch.xpu._is_compiled():
|
||||
return False
|
||||
return torch.xpu.is_initialized()
|
||||
|
||||
|
||||
def cuda_get_device_properties(device,
|
||||
names: Sequence[str],
|
||||
init_cuda=False) -> tuple[Any, ...]:
|
||||
@@ -2848,6 +2855,8 @@ def _maybe_force_spawn():
|
||||
reason = None
|
||||
if cuda_is_initialized():
|
||||
reason = "CUDA is initialized"
|
||||
elif xpu_is_initialized():
|
||||
reason = "XPU is initialized"
|
||||
elif is_in_ray_actor():
|
||||
# even if we choose to spawn, we need to pass the ray address
|
||||
# to the subprocess so that it knows how to connect to the ray cluster.
|
||||
|
||||
Reference in New Issue
Block a user