nvidia驅動升級和nvidia-docker2安裝

1.nvidia驅動安裝

(1)移除舊驅動

sudo apt-get purge nvidia\*  
#部分 Debian 系發行版版本可能不支持 apt-get purge ,可嘗試使用 apt-get remove –purge 或 apt-get autoremove –purge 替代

(2)添加驅動 PPA

# Add the graphics-driver PPA
sudo add-apt-repository ppa:graphics-drivers
# And update
sudo apt-get update 

(3)查詢顯卡驅動https://www.nvidia.com/Download/index.aspx?lang=en-us
或者

ubuntu-drivers devices   # 查詢所有ubuntu推薦的驅動

(4)安裝(啓用)最新 Nvidia 顯卡驅動

sudo apt-get install nvidia-你的版本號

(5)重啓電腦以使新驅動生效

reboot

lsmod | grep nvidia

Ubuntu下安裝Docker

添加阿里Docker鏡像源

參考 https://yq.aliyun.com/articles/110806?commentId=11066

如果之前安裝過Docker的舊版本,可以使用下面的命令進行卸載:


sudo apt-get remove docker docker-engine docker.io

Ubuntu 14.04 16.04 (使用apt-get進行安裝)

# step 1: 安裝必要的一些系統工具
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# step 2: 安裝GPG證書
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Step 3: 寫入軟件源信息
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# Step 4: 更新並安裝 Docker-CE
sudo apt-get -y update
sudo apt-get -y install docker-ce

# 安裝指定版本的Docker-CE:
# Step 1: 查找Docker-CE的版本:
# apt-cache madison docker-ce
#   docker-ce | 17.03.1~ce-0~ubuntu-xenial | http://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
#   docker-ce | 17.03.0~ce-0~ubuntu-xenial | http://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
# Step 2: 安裝指定版本的Docker-CE: (VERSION 例如上面的 17.03.1~ce-0~ubuntu-xenial)
# sudo apt-get -y install docker-ce=[VERSION]

安裝校驗


root@iZbp12adskpuoxodbkqzjfZ:$ docker version
Client:
 Version:      17.03.0-ce
 API version:  1.26
 Go version:   go1.7.5
 Git commit:   3a232c8
 Built:        Tue Feb 28 07:52:04 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.03.0-ce
 API version:  1.26 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   3a232c8
 Built:        Tue Feb 28 07:52:04 2017
 OS/Arch:      linux/amd64
 Experimental: false

也可以用systemctl status docker.service查看Docker運行狀態。

安裝nvidia-docker

參考 https://github.com/NVIDIA/nvidia-docker
這裏只說一下Ubuntu的,其他Linux變種的安裝方式在Github上可以找到。

# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
sudo apt-get purge -y nvidia-docker

# Add the package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
  sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update

# Install nvidia-docker2 and reload the Docker daemon configuration
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd

# Test nvidia-smi with the latest official CUDA image
docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi

(2)根據需要拉取自己的docker

https://hub.docker.com/上查看自己需要的docker並pull下來

例如

docker pull pytorch/pytorch:1.4-cuda10.1-cudnn7-devel;

#創建容器
nvidia-docker run --name=wangxp1   -d -e GPUID="0" -e INSTANTID="1"  -it -p 12345:12345 -v /home/wangxp1:/workspace -d pytorch/pytorch:1.3-cuda10.1-cudnn7-devel

啓動docker

docker start wangxp1

進入docker有兩種方法

#1.可以多人同時進入,並分別操作

docker exec -it wangxp1 bash

#2可以多人同時進入,但都是一個操作

docker attach wangxp1
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章