Nvidia driver upgrade

Upgrade nvidia dirver

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt upgrade

加了NVIDIA的Repo後就可以在更新Driver那裡更新了

Install cuDNN

去nvidia官網找個package安裝, 注意要對應cuda ver, 目前我用cuda 10.2, cudnn 7.6

Setup nvidia cuda環境

# 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

中間會問daemon跟tensorflow setting還是用自己的, 先backup自己的再merge, eg.

{
    "storage-driver": "overlay2",
    "data-root": "/data/Docker",
    "runtimes": {
        "nvidia": {
            "path": "nvidia-container-runtime",
            "runtimeArgs": []
        }
    }
}

Optional:

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

背景運行tensorflow container, 選了py3和jupyter環境, runtime選nvidia啟用GPU

docker run --runtime nvidia --name tf -d --rm -v /data/workspace/DockerVolume/Notebooks:/tf/notebooks -p 8888:8888 tensorflow/tensorflow:nightly-gpu-py3-jupyter

進入jupyter notebook需要token, 這邊看

docker logs tf

檢查tf version & 是不是在用GPU

import tensorflow as tf
print(tf.__version__)
tf.test.gpu_device_name()