You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker镜像中add-apt-repository缺失及CUDA安装失败求助

解决Anaconda3 2020.11 Docker镜像中安装CUDA 11.8的问题

问题根源
你使用的continuumio/anaconda3:2020.11镜像基于Debian 10(Buster),而非Debian 11,直接套用Debian11的CUDA安装教程会导致源不兼容;加上镜像默认的Debian源已过期,因此出现404错误和add-apt-repository执行失败的问题。

步骤1:替换为可用的Debian 10源

先备份旧源文件,替换为国内可用的Debian Buster源以解决404问题:

# 备份原源文件
cp /etc/apt/sources.list /etc/apt/sources.list.bak

# 替换为清华Debian Buster源
cat > /etc/apt/sources.list << EOF
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
EOF

# 更新源缓存
apt update

步骤2:安装必要依赖

现在可以正常安装software-properties-common及其他辅助工具:

apt install -y software-properties-common gnupg2 curl

步骤3:添加CUDA 11.8的Debian 10官方源

CUDA 11.8支持Debian 10,添加对应版本的官方源:

# 导入NVIDIA GPG密钥
curl https://developer.download.nvidia.com/compute/cuda/repos/debian10/x86_64/cuda-keyring_1.0-1_all.deb -o cuda-keyring.deb
dpkg -i cuda-keyring.deb

# 添加CUDA 11.8源配置
echo "deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/debian10/x86_64/ /" > /etc/apt/sources.list.d/cuda.list

# 更新源缓存
apt update

步骤4:安装CUDA 11.8

根据需求选择安装完整工具包或仅runtime:

# 安装完整CUDA 11.8工具包(适合开发场景)
apt install -y cuda-11-8

# 或者仅安装CUDA runtime(适合推理场景)
# apt install -y cuda-runtime-11-8

步骤5:配置CUDA环境变量

将CUDA路径添加到系统环境变量,确保终端和conda环境能识别:

echo 'export PATH=/usr/local/cuda-11.8/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc

# 生效环境变量
source ~/.bashrc

验证安装

执行以下命令确认CUDA安装成功:

nvcc --version
nvidia-smi  # 需使用nvidia-docker启动容器才能检测到GPU

内容的提问来源于stack exchange,提问作者easythrees

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 02:30:01