一、问题分析
最近在使用分析服务器,出现torch无法正常使用的情况,import torch print(torch.cuda.is_available())输出如下错误提示信息UserWarning: CUDA initialization: Unexpected error from cudaGetDeviceCount(). Did you run some cuda functions before calling NumCudaDevices() that might have already set an error? Error 802:system not yet initialized
经过一番折腾,发现驱动与CUDA都能正常运行,那问题就只能出在NVLink上了,通过搜索发现,A系列显卡或者H100如果需要使用NVLink或者NVSwith进行连接,需要安装nvidia-fabricmanager服务,并且需要与驱动版本保持一致
二、解决方案
1.这个包nvidia-fabricmanager重新安装对应兼容版本(如我这里需要安装535.230.02版本),然后把自动更新禁用掉。另外要保证这个服务正常运行nvidia-fabricmanager,可以设置开机自动启动,
2.查看服务器用的系统是ubuntu22.04 查看命令是 cat /etc/issue ,然后到官网下载Index of /compute/cuda/repos/ubuntu2204/x86_64 下载如图
3.设置操作如下
wget https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2204/x86_64/nvidia-fabricmanager-535_535.230.02-1_amd64.deb
apt-get remove nvidia-fabricmanager-535
apt-get install ./nvidia-fabricmanager-535_535.230.02-1_amd64.deb
systemctl enable nvidia-fabricmanager
systemctl restart nvidia-fabricmanager
systemctl status nvidia-fabricmanager
4.重新测试下,完美解决
import torch
print(torch.cuda.is_available())