Cannot determine the device from pointer using `cudaPointerGetAttributes` if device mismatch
See original GitHub issueIt seems cudaPointerGetAttributes
(and cuPointerGetAttributes
) is no longer working in CUDA 10.1+ if the device the pointer resides and the current device do not match. It was working in CUDA 10.0.
import cupy
a = cupy.arange(10) # array on GPU 0
cupy.cuda.Device(0).use()
cupy.cuda.runtime.pointerGetAttributes(a.data.ptr)
cupy.cuda.Device(1).use()
cupy.cuda.runtime.pointerGetAttributes(a.data.ptr) # raises CUDARuntimeError
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "cupy_backends/cuda/api/runtime.pyx", line 601, in cupy_backends.cuda.api.runtime.pointerGetAttributes
cpdef PointerAttributes pointerGetAttributes(intptr_t ptr):
File "cupy_backends/cuda/api/runtime.pyx", line 604, in cupy_backends.cuda.api.runtime.pointerGetAttributes
check_status(status)
File "cupy_backends/cuda/api/runtime.pyx", line 246, in cupy_backends.cuda.api.runtime.check_status
raise CUDARuntimeError(status)
cupy_backends.cuda.api.runtime.CUDARuntimeError: cudaErrorInvalidValue: invalid argument
We rely on cudaPointerGetAttributes
to determine the device for foreign pointers, e.g., __cuda_array_interface__
which does not contain the device number.
https://github.com/cupy/cupy/blob/v8.0.0rc1/cupy/cuda/memory.pyx#L123
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Detection if a pointer is pointing in the device or host in CUDA
This is a small example showing how Unified Virtual Addressing can be used to detect if a pointer is pointing to host or...
Read more >host & device pointer mismatch detection
Hi, I'm still learning and took me 20 minutes to figure out why I get execution error under debugger: Cuda error: vecSum Kernel...
Read more >cudart - CUDA Python 12.0.0 documentation - GitHub Pages
Opens an interprocess memory handle exported from another process and returns a device pointer usable in the local process.
Read more >CUDA C Programming Guide
Clarified that values of const-qualified variables with builtin floating-point types cannot be used directly in device code when the Microsoft compiler is ...
Read more >CUDA Runtime API - 5.11. Unified Addressing
CUDA devices can share a unified address space with the host. ... one may want to know if a pointer points to host...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue is related to timing of CUDA context creation. If you allocate memory on “current” GPU before calling cudaPointGetAttributes(), this issue can be avoided.
We’re checking with the CUDA team, so please wait for a while.