设置显卡为非独占模式,解决CUDA error: all CUDA-capable devices are busy or unavailable CUDA kernel errors might b

当调用显卡时,报错:CUDA error: all CUDA-capable devices are busy or unavailable CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1

再看nvidia-smi显卡信息,最右边一列,Volatile Uncorr. ECC GPU-Util MIG M.这里,显示的是E.Process Disabled
在这里插入图片描述

原因:这是因为显卡设置了独占模式
解决方案:解除显卡的独占模式:

nvidia-smi -c 0                        #设置所有显卡为独占模式False
user:~$ sudo nvidia-smi -c 0
[sudo] password for speed:
Set compute mode to DEFAULT for GPU 00000000:01:00.0.
Set compute mode to DEFAULT for GPU 00000000:02:00.0.
All done.

非独占模式的显示:
在这里插入图片描述