1 离线安装Nvidia Driver
参考网址:
Deepin 20.9在GTX 1060显卡上安装Nvidia 550.100驱动
2 离线安装Docker Engine
- 卸载旧版本包
# 强制删除docker的缓存
docker system prune -a --force
# 卸载docker相关安装包
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
wget https://download.docker.com/linux/debian/dists/bullseye/pool/stable/amd64/containerd.io_1.7.19-1_amd64.deb
wget https://download.docker.com/linux/debian/dists/bullseye/pool/stable/amd64/docker-ce-cli_27.0.3-1~debian.11~bullseye_amd64.deb
wget https://download.docker.com/linux/debian/dists/bullseye/pool/stable/amd64/docker-ce_27.0.3-1~debian.11~bullseye_amd64.deb
wget https://download.docker.com/linux/debian/dists/bullseye/pool/stable/amd64/docker-buildx-plugin_0.15.1-1~debian.11~bullseye_amd64.deb
wget https://download.docker.com/linux/debian/dists/bullseye/pool/stable/amd64/docker-compose-plugin_2.28.1-1~debian.11~bullseye_amd64.deb
- 安装相关软件
sudo dpkg -i ./containerd.io_1.7.19-1_amd64.deb \
./docker-ce-cli_27.0.3-1~debian.11~bullseye_amd64.deb \
./docker-ce_27.0.3-1~debian.11~bullseye_amd64.deb \
./docker-buildx-plugin_0.15.1-1~debian.11~bullseye_amd64.deb \
./docker-compose-plugin_2.28.1-1~debian.11~bullseye_amd64.deb
- 添加镜像源
# 添加镜像源
sudo vim /etc/docker/daemon.json
{
"registry-mirrors": [
"https://hub.uuuadc.top",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com",
"https://docker.anyhub.us.kg",
"https://dockerhub.jobcher.com",
"https://dockerhub.icu",
"https://docker.ckyl.me",
"https://docker.awsl9527.cn",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.nju.edu.cn",
"https://docker.m.daocloud.io",
"https://dockerproxy.com",
"https://registry.docker-cn.com",
"https://hub-mirror.c.163.com"
]
}
# 使配置生效
sudo systemctl daemon-reload
# 重启Docker
sudo systemctl restart docker
- 添加root权限
sudo groupadd docker # 添加docker用户组
sudo usermod -aG docker $USER # 将当前用户添加到docker用户组
newgrp docker # 更新用户组
docker info # 测试docker命令是否可以使用sudo正常使用
reboot # 重启系统
- 验证安装成功
sudo service docker start
sudo docker run --rm hello-world
参考网址:
7 离线安装Nvidia Container Toolkit
# libnvidia-container及其工具包
libnvidia-container1_1.13.5-1_amd64.deb
libnvidia-container-tools_1.13.5-1_amd64.deb
# nvidia-container-toolkit及其基础文件
nvidia-container-toolkit-base_1.13.5-1_amd64.deb
nvidia-container-toolkit_1.13.5-1_amd64.deb
# nvidia-container-runtime
nvidia-container-runtime_3.13.0-1_all.deb
# nvidia-docker2
nvidia-docker2_2.13.0-1_all.deb
# libnvidia-container开发调试包(一般不需要安装)
libnvidia-container-dev_1.13.5-1_amd64.deb
libnvidia-container1-dbg_1.13.5-1_amd64.deb
- 安装相关软件
# 安装相关软件
sudo dpkg -i ./libnvidia-container1_1.13.5-1_amd64.deb \
./libnvidia-container-tools_1.13.5-1_amd64.deb \
./nvidia-container-toolkit-base_1.13.5-1_amd64.deb \
./nvidia-container-toolkit_1.13.5-1_amd64.deb \
./nvidia-container-runtime_3.13.0-1_all.deb \
./nvidia-docker2_2.13.0-1_all.deb
# 修复依赖关系
sudo apt-get install -f
- 添加镜像源
# 添加镜像源
sudo vim /etc/docker/daemon.json
{
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
},
"registry-mirrors": [
"https://hub.uuuadc.top",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com",
"https://docker.anyhub.us.kg",
"https://dockerhub.jobcher.com",
"https://dockerhub.icu",
"https://docker.ckyl.me",
"https://docker.awsl9527.cn",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.nju.edu.cn",
"https://docker.m.daocloud.io",
"https://dockerproxy.com",
"https://registry.docker-cn.com",
"https://hub-mirror.c.163.com"
]
}
# 使配置生效
sudo systemctl daemon-reload
# 重启Docker
sudo systemctl restart docker
- 验证安装成功
sudo systemctl restart docker
docker run --gpus all --rm nvcr.io/nvidia/cuda nvidia-smi
参考网址:
- 配置 Docker 使用 GPU
- Ubuntu20.04 arm64/amd64 离线安装nvidia-docker2
- docker 使用gpu
- libnvidia-container
- NVIDIA Container Toolkit repository
- Docker 配置国内镜像源加速