CUDA Runtime API error 46: all CUDA-capable devices are busy or unavailable

Cuda8 on top of centos7 and having Nvidia Geforce940m GPU and Intel HD Graphics 520(skylake GT2). What is the cause of error?

If the app you are using is making use of CUDA/OGL interop, then this may happen when your OGL context gets instantiated on the HD Graphics and the CUDA context gets established on the 940m.

In that case, the solution is to force the OGL context to get instantiated on the NVIDIA GPU.

In that case, google “Optimus CUDA application profile”

Thanks tbob. it seems the GPU switching problem.
why the nvidia-pprime package is not available for centos? what are alternatives to solve this issue?