Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test1: does not need getDevice, cause setDevice() will set currentDev… #757

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions dipu/tests/python/individual_scripts/test_rt_ddp.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ def forward(self, x):
def demo_basic_ddp(rank, world_size, port):
import torch_dipu

print(f"Running basic DDP example on rank {rank} {torch.cuda.current_device()}")
# print(f"Running basic DDP example on rank {rank} {torch.cuda.current_device()}")
torch.cuda.set_device(rank)
print(f"Running basic DDP example on rank {rank} {torch.cuda.current_device()}")
backend = "nccl"
dev1 = rank

Expand Down Expand Up @@ -100,8 +101,9 @@ def demo_basic_ddp(rank, world_size, port):
def demo_allreduce(rank, world_size, port):
import torch_dipu

print(f"Running basic DDP example on rank {rank} {torch.cuda.current_device()}")
# print(f"Running basic DDP example on rank {rank} {torch.cuda.current_device()}")
torch.cuda.set_device(rank)
print(f"Running basic DDP example on rank {rank} {torch.cuda.current_device()}")
dev1 = rank

setup(rank, world_size, port)
Expand Down Expand Up @@ -151,7 +153,7 @@ def demo_allgather(rank, world_size, port):
import torch_dipu

setup(rank, world_size, port)

print(f"rank={rank}")
src1 = torch.ones((2, 4)).to(rank)
dests = torch.zeros((world_size * 2, 4)).to(rank)
dests = [
Expand Down
2 changes: 1 addition & 1 deletion dipu/torch_dipu/csrc_dipu/vendor/ascend/deviceimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void finalizeVendor() { DIPU_CALLACLRT(aclFinalize()); }
deviceId_t current_device() {
if (currentDeviceIndex < 0) {
setDevice(-1);
DIPU_CALLACLRT(::aclrtGetDevice(&currentDeviceIndex))
// DIPU_CALLACLRT(::aclrtGetDevice(&currentDeviceIndex))
}
return static_cast<deviceId_t>(currentDeviceIndex);
}
Expand Down