File tree Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change @@ -60,12 +60,10 @@ UniqueAVBufferRef getHardwareDeviceContext(const torch::Device& device) {
6060
6161 // Create hardware device context
6262 c10::cuda::CUDAGuard deviceGuard (device);
63- // Valid values for the argument to cudaSetDevice are 0 to maxDevices - 1:
64- // https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g159587909ffa0791bbe4b40187a4c6bb
65- // So we ensure the deviceIndex is not negative.
6663 // We set the device because we may be called from a different thread than
6764 // the one that initialized the cuda context.
68- cudaSetDevice (deviceIndex);
65+ TORCH_CHECK (
66+ cudaSetDevice (deviceIndex) == cudaSuccess, " Failed to set CUDA device" );
6967 AVBufferRef* hardwareDeviceCtxRaw = nullptr ;
7068 std::string deviceOrdinal = std::to_string (deviceIndex);
7169
You can’t perform that action at this time.
0 commit comments