Spaces:
Runtime error
Runtime error
namespace at::cuda { | |
inline Device getDeviceFromPtr(void* ptr) { | |
cudaPointerAttributes attr{}; | |
AT_CUDA_CHECK(cudaPointerGetAttributes(&attr, ptr)); | |
TORCH_CHECK(attr.type != cudaMemoryTypeUnregistered, | |
"The specified pointer resides on host memory and is not registered with any CUDA device."); | |
return {c10::DeviceType::CUDA, static_cast<DeviceIndex>(attr.device)}; | |
} | |
} // namespace at::cuda | |