docker 内 pytorch cuda 不可用
NVIDIA 在 /usr/local/cuda/compat/ 目录下提供了一些兼容库 (libcuda.so.1 等),但如果主机的 NVIDIA 驱动版本较新,则不需要这些兼容库。强行使用这些库可能会导致不匹配的 CUDA 版本,从而触发 Error 804。conda 安装2.5.0 的 pytorch 后,使用 cuda 报错。拉的官方 docker 仓库里的镜像。nvidia-smi
·
拉的官方 docker 仓库里的镜像
nvidia/cuda:12.4.1-cudnn-devel-rockylinux8
conda 安装2.5.0 的 pytorch 后,使用 cuda 报错
(myenv) [root@000b4321253c opt]# python test1.py
可用 GPU 数量: 1
检测 CUDA 时出错: Unexpected error from cudaGetDeviceCount(). Did you run some cuda functions before calling NumCudaDevices() that might have already set an error? Error 804: forward compatibility was attempted on non supported HW
我的 test1.py 代码
import torch
try:
device_count = torch.cuda.device_count()
print("可用 GPU 数量:", device_count)
for i in range(device_count):
print(f"GPU {i}: {torch.cuda.get_device_name(i)}")
except Exception as e:
print("检测 CUDA 时出错:", e)
nvidia-smi 可以执行
直接贴原因:
NVIDIA 在 /usr/local/cuda/compat/ 目录下提供了一些兼容库 (libcuda.so.1 等),但如果主机的 NVIDIA 驱动版本较新,则不需要这些兼容库。强行使用这些库可能会导致不匹配的 CUDA 版本,从而触发 Error 804。
解决方案:
rm -rf /usr/local/cuda/compat

欢迎来到由智源人工智能研究院发起的Triton中文社区,这里是一个汇聚了AI开发者、数据科学家、机器学习爱好者以及业界专家的活力平台。我们致力于成为业内领先的Triton技术交流与应用分享的殿堂,为推动人工智能技术的普及与深化应用贡献力量。
更多推荐
所有评论(0)