Docker GPU

Submitted by Lizhe on Thu, 07/30/2020 - 09:16

 

插播一个备忘录

sudo apt install docker.io

sudo usermod -a -G docker lizhe

然后正常退出,重启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

sudo apt-get update

sudo apt-get install -y nvidia-container-toolkit

sudo systemctl restart docker

 

docker run --gpus all nvidia/cuda:10.0-base nvidia-smi

20200730051942

 

docker run --gpus all --name tensorflow1 -it -p 8080:8888 tensorflow/tensorflow:latest-gpu-py3-jupyter

 

import tensorflow as tf
import os

os.environ['TF_CPP_MIN_LOG_LEVEL']='2'

a = tf.constant(1.)
b = tf.constant(2.)
print(a+b)

print('GPU:', tf.test.is_gpu_available())

 

20200730054353