Skip to content

Commit 5265631

Browse files
authored
use a correct device when creating OptionalCUDAGuard (#2583)
1 parent 2832e7b commit 5265631

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

csrc/cache_kernels.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void swap_blocks(
3434
char *dst_ptr = static_cast<char*>(dst.data_ptr());
3535

3636
const int64_t block_size_in_bytes = src.element_size() * src[0].numel();
37-
const at::cuda::OptionalCUDAGuard device_guard(src_device);
37+
const at::cuda::OptionalCUDAGuard device_guard(src_device.is_cuda() ? src_device : dst_device);
3838
const cudaStream_t stream = at::cuda::getCurrentCUDAStream();
3939
// NOTE(woosuk): This can be slow if the number of blocks is large.
4040
for (const auto& pair : block_mapping) {

0 commit comments

Comments
 (0)