简体   繁体   中英

Unexpected CUDA_ERROR_INVALID_VALUE from cuLaunchKernel()

I'm trying to launch a kernel using the CUDA driver API. Specifically I'm calling

CUresult CUDAAPI cuLaunchKernel(
    CUfunction f,
    unsigned int gridDimX,  unsigned int gridDimY,  unsigned int gridDimZ,
    unsigned int blockDimX, unsigned int blockDimY, unsigned int blockDimZ,
    unsigned int sharedMemBytes,
    CUstream hStream,
    void **kernelParams,
    void **extra);

I'm only using kernelParams , and passing nullptr for extra . Now, for one of my kernels, I get CUDA_ERROR_INVALID_VALUE .

The documentation says :

The error CUDA_ERROR_INVALID_VALUE will be returned if kernel parameters are specified with both kernelParams and extra (ie both kernelParams and extra are non- NULL ).

well, I'm not doing that, and am still getting CUDA_ERROR_INVALID_VALUE . To be extra-safe, I synch'ed the stream right before launching the kernel - but to no avail.

What are the other reasons for getting CUDA_ERROR_INVALID_VALUE when trying to launch?

Apparently, you can get a CUDA_ERROR_INVALID_VALUE error in multiple cases involving issues with your kernelParams and/or extras arguments:

  1. Both kernelParams and extras are null, but the kernel takes parameters.
  2. Both kernelParams and extras are non-null (this is what's officially documented)
  3. The number of elements in kernelParams before the terminating nullptr value doesn't match the number of kernel parameters.

and this is not an exhaustive list. Probably misusing extras can cause this too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM