0

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 (i.e. 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?

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • Your textualist reading of selected parts of the documentation is getting in the way again. That isn't the only condition which can return CUDA_ERROR_INVALID_VALUE. Any incorrect arguments other than the function itself will also produce the same error – talonmies Aug 16 '20 at 11:14
  • @talonmies: Including the grid dims and block dims? excessive shared memory? invalid stream handle? – einpoklum Aug 16 '20 at 11:20

1 Answers1

1

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.

einpoklum
  • 118,144
  • 57
  • 340
  • 684