[Hardware] Replace torch.cuda.device_count/current_device/set_device API (#36145)
Signed-off-by: Kunshang Ji <jikunshang95@gmail.com> Signed-off-by: Kunshang Ji <kunshang.ji@intel.com>
This commit is contained in:
@@ -491,7 +491,7 @@ class FlashInferAllToAllManager(All2AllManagerBase):
|
||||
self.initialize(
|
||||
world_size=self.world_size,
|
||||
rank=self.rank,
|
||||
gpus_per_node=torch.cuda.device_count,
|
||||
gpus_per_node=torch.accelerator.device_count,
|
||||
)
|
||||
return self.initialized
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ class nccl_symm_mem_context:
|
||||
self.pynccl_comm = pynccl_comm
|
||||
self._mem_pool_ctx = torch.cuda.use_mem_pool(get_nccl_mem_pool())
|
||||
self.is_graph_capture = torch.cuda.is_current_stream_capturing()
|
||||
self.device = torch.cuda.current_device()
|
||||
self.device = torch.accelerator.current_device_index()
|
||||
|
||||
def __enter__(self):
|
||||
if self.disabled:
|
||||
|
||||
@@ -50,7 +50,7 @@ class SymmMemCommunicator:
|
||||
device = torch.device(f"cuda:{device}")
|
||||
elif isinstance(device, str):
|
||||
device = torch.device(device)
|
||||
torch.cuda.set_device(device)
|
||||
torch.accelerator.set_device_index(device)
|
||||
self.dtype = torch.bfloat16
|
||||
self.device = device
|
||||
self.group = group
|
||||
|
||||
Reference in New Issue
Block a user