@@ -22,7 +22,7 @@ def all_reduce_test_worker(tp_size: int, pp_size: int, rank: int,
2222 # it is important to delete the CUDA_VISIBLE_DEVICES environment variable
2323 # so that each worker can see all the GPUs
2424 # they will be able to set the device to the correct GPU
25- del os .environ [ "CUDA_VISIBLE_DEVICES" ]
25+ os .environ . pop ( "CUDA_VISIBLE_DEVICES" , None )
2626 device = torch .device (f"cuda:{ rank } " )
2727 torch .cuda .set_device (device )
2828 init_test_distributed_environment (tp_size , pp_size , rank ,
@@ -44,7 +44,7 @@ def all_gather_test_worker(tp_size: int, pp_size: int, rank: int,
4444 # it is important to delete the CUDA_VISIBLE_DEVICES environment variable
4545 # so that each worker can see all the GPUs
4646 # they will be able to set the device to the correct GPU
47- del os .environ [ "CUDA_VISIBLE_DEVICES" ]
47+ os .environ . pop ( "CUDA_VISIBLE_DEVICES" , None )
4848 device = torch .device (f"cuda:{ rank } " )
4949 torch .cuda .set_device (device )
5050 init_test_distributed_environment (tp_size , pp_size , rank ,
@@ -72,7 +72,7 @@ def broadcast_tensor_dict_test_worker(tp_size: int, pp_size: int, rank: int,
7272 # it is important to delete the CUDA_VISIBLE_DEVICES environment variable
7373 # so that each worker can see all the GPUs
7474 # they will be able to set the device to the correct GPU
75- del os .environ [ "CUDA_VISIBLE_DEVICES" ]
75+ os .environ . pop ( "CUDA_VISIBLE_DEVICES" , None )
7676 device = torch .device (f"cuda:{ rank } " )
7777 torch .cuda .set_device (device )
7878 init_test_distributed_environment (tp_size , pp_size , rank ,
@@ -108,7 +108,7 @@ def broadcast_tensor_dict_test_worker(tp_size: int, pp_size: int, rank: int,
108108@ray .remote (num_gpus = 1 , max_calls = 1 )
109109def send_recv_tensor_dict_test_worker (tp_size : int , pp_size : int , rank : int ,
110110 distributed_init_port : str ):
111- del os .environ [ "CUDA_VISIBLE_DEVICES" ]
111+ os .environ . pop ( "CUDA_VISIBLE_DEVICES" , None )
112112 device = torch .device (f"cuda:{ rank } " )
113113 torch .cuda .set_device (device )
114114 init_test_distributed_environment (tp_size , pp_size , rank ,
@@ -148,7 +148,7 @@ def send_recv_tensor_dict_test_worker(tp_size: int, pp_size: int, rank: int,
148148@ray .remote (num_gpus = 1 , max_calls = 1 )
149149def send_recv_test_worker (tp_size : int , pp_size : int , rank : int ,
150150 distributed_init_port : str ):
151- del os .environ [ "CUDA_VISIBLE_DEVICES" ]
151+ os .environ . pop ( "CUDA_VISIBLE_DEVICES" , None )
152152 device = torch .device (f"cuda:{ rank } " )
153153 torch .cuda .set_device (device )
154154 init_test_distributed_environment (tp_size , pp_size , rank ,
0 commit comments