Skip to content
Merged
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
7 changes: 7 additions & 0 deletions c10/cuda/impl/CUDAGuardImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,17 @@ struct CUDAGuardImpl final : public c10::impl::DeviceGuardImplInterface {
}
return Device(DeviceType::CUDA, device);
}
#if CUDA_VERSION >= 12000
void setDevice(Device d) const override {
TORCH_INTERNAL_ASSERT(d.is_cuda());
C10_CUDA_CHECK(c10::cuda::MaybeSetDevice(d.index()));
}
#else
void setDevice(Device d) const override {
TORCH_INTERNAL_ASSERT(d.is_cuda());
C10_CUDA_CHECK(c10::cuda::SetDevice(d.index()));
}
#endif
void uncheckedSetDevice(Device d) const noexcept override {
C10_CUDA_CHECK_WARN(c10::cuda::MaybeSetDevice(d.index()));
}
Expand Down