跳转至

安装docker及英伟达docker

安装docker

# 配置环境
apt-get remove docker docker-engine docker.io && apt-get update && apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release
# 添加软件源的 GPG 密钥
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# 添加 Docker 软件源(镜像)
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# 安装
apt-get update && apt-get -y install docker-ce docker-ce-cli containerd.io

启动和安装英伟达docker

启动docker时可以带上GPU

docker run -it --entrypoint bash --gpus all  wojiazaiyugang/high-venue-server:latest
如果没有安装英伟达docker的话会报错
docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].
ERRO[0000] error waiting for container: context canceled
如果需要在docker内使用英伟达GPU的话需要安装nvidia-docker
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) && curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - && curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list

apt-get update && apt-get install -y nvidia-docker2  && systemctl restart docker

评论