问题描述

执行nvidia-smi正常,但是执行nvcc -V报bash: nvcc: command not found,这会导致你需要进行编译代码时,由于找不到NVIDIA ® Cuda compiler driver而报错。

解决方案

如果你的镜像基于runtime,则只包含运行时环境,不包含cuda编译环境,如pytorch/pytorch:2.3.1-cuda12.1-cudnn8-runtime,可以考虑把父镜像修改成pytorch/pytorch:2.3.1-cuda12.1-cudnn8-devel
如果你无法修改父镜像,可以在当前容器中安装cuda

# 网络不行则需要配置代码,地址去:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
cp /etc/apt/sources.list /etc/apt/sources.list.bak
cat <<EOF > /etc/apt/sources.list
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse

# deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
EOF

# 安装cuda toolkit
apt install nvidia-cuda-toolkit

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部