I just want to use Driver api cuMemAlloc allocate 4 bytes. But The CUDA_ERROR_ILLEGAL_ADDRESS exception happend.
I am curious which situation the allocate api throw CUDA_ERROR_ILLEGAL_ADDRESS. As far as I know, The cuMemAlloc will failed because out of memory. I don’t know the reason lead to illegal address. Please help me.

CUdeviceptr nativeDptr;
int result = cuMemAlloc(&nativeDptr, (size_t)4);

it may be the result of a previous kernel call

cuda kernel call error reporting is asynchronous

It will be reported on the next CUDA (runtime or driver) API call after the error occurs.

One possible suggestion is to use rigorous error checking with a device synchronization after each kernel call to localize such errors. The device synchronization need not be part of your production code if you don’t wish such; just include it for debug purposes.

Alternatively, run your code with cuda-memcheck