项目场景:
測試torch安裝是否成功,輸入:
python
import torch
torch.cuda.is_available()
顯示如下,安裝不成功。
问题描述:
UserWarning: CUDA initialization: CUDA unknown error - this may be due to an incorrectly set up environment, e.g. changing env variable CUDA_VISIBLE_DEVICES after program start. Setting the available devices to be zero. (Triggered internally at /opt/conda/conda-bld/pytorch_1614378083779/work/c10/cuda/CUDAFunctions.cpp:109.)
return torch._C._cuda_getDeviceCount() > 0
原因分析:
nvidia-modprobe 版本过低或未安裝,与显卡驱动的版本不匹配,将nvidia-modprobe更新至与显卡驱动的版本一致即可。
解决方案:
apt-get install nvidia-modprobe