Search code examples
javacudacontrolpaneljcuda

cuCtxCreate fails if NVIDIA control panel sets optimization for computing


I run CUDA through JCuda API. When I use NVIDIA control panel to set optimization for computing (that is off by default) for participating JVM executable (java.exe), the program fails to create context in the call to cuCtxCreate.

For optimization set off, the program runs just fine. The only problem was too high deviation of elapsed time in the kernel (~50%) from run to run. I was searching for ways to get CUDA cores in something like monopoly mode, just to get more stable result.

Do I misunderstand this parameter in control panel?

Exception in thread "main" jcuda.CudaException: CUDA_ERROR_UNKNOWN at jcuda.driver.JCudaDriver.checkResult(JCudaDriver.java:353) at jcuda.driver.JCudaDriver.cuCtxCreate(JCudaDriver.java:1606) at com.varankin.cuda.CudaContext.(CudaContext.java:21)

Configuration:

  • Intel i7-4510U with integrated graphics, that is set as default GPU.
  • NVIDIA GeForce 840M on shared memory space.
  • Windows 10
  • Java 8, rev. 152
  • JCuda-All-0.9.0d-bin-x86_64
  • CUDA from cuda_9.2.148_win10.exe

Solution

  • For optimization set off, the program runs just fine. The only problem was too high deviation of elapsed time in the kernel (~50%) from run to run.

    That is likely cause by WDDM driver batching of computing commands, If you search around you will find some suggestions you can try to minimize its negative effect.

    I was searching for ways to get CUDA cores in something like monopoly mode, just to get more stable result.

    That type of mode of operation only exists for Tesla and certain Quadro GPUs using TCC mode on Windows. Your GPU cannot be used in that way.

    Do I misunderstand this parameter in control panel?

    Yes. Quoting from the documentation:

    Windows 10, Maxwell GPUs and later.
    Offers significant improvement for some Compute applications.
    Care should be taken when turning this setting ON, as there can
    be unpredictable effects with some applications and graphics features.
    

    Giving that warning, the safe thing to do is leave that setting off.