sudo apt-get update
sudo apt-get install \\ca-certificates \\curl \\gnupg \\lsb-release
sudo mkdir -p /etc/apt/keyringscurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpgecho \\"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \\$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \\&& curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \\&& curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \\sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \\sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker
sudo docker run --rm --gpus all nvidia/cuda:11.0.3-base-ubuntu20.04 nvidia-smi
+-----------------------------------------------------------------------------+| NVIDIA-SMI 450.51.06 Driver Version: 450.51.06 CUDA Version: 11.0 ||-------------------------------+----------------------+----------------------+| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC || Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. || | | MIG M. ||===============================+======================+======================|| 0 Tesla T4 On | 00000000:00:1E.0 Off | 0 || N/A 34C P8 9W / 70W | 0MiB / 15109MiB | 0% Default || | | N/A |+-------------------------------+----------------------+----------------------++-----------------------------------------------------------------------------+| Processes: || GPU GI CI PID Type Process name GPU Memory || ID ID Usage ||=============================================================================|| No running processes found |+-----------------------------------------------------------------------------+
Tag | Description |
latest | Latest (default) tag of the binary TensorFlow CPU image. |
nightly | Nightly tag of the TensorFlow image, which is unstable. |
version | Tag of the TensorFlow binary image, such as `2.1.0`. |
devel | TensorFlow masterNightly tag of the development environment, which contains the TensorFlow source code. |
custom-op | Special experimental image for custom TensorFlow operation development. For more information, see tensorflow/custom-op. |
Tag Variant | Description |
tag -gpu | Specified tag supporting GPU. |
tag -jupyter | Specified tag for Jupyter, which contains the TensorFlow tutorial laptop. |
docker pull tensorflow/tensorflow # latest stable releasedocker pull tensorflow/tensorflow:devel-gpu # nightly dev release w/ GPU supportdocker pull tensorflow/tensorflow:latest-gpu-jupyter # latest release w/ GPU support and Jupyter
docker run [-it] [--rm] [-p hostPort:containerPort] tensorflow/tensorflow[:tag] [command]
latest
tag to verify the TensorFlow installation result. Docker will download the latest TensorFlow image when it runs for the first time.docker run -it --rm tensorflow/tensorflow \\python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
bash
shell session in the container where TensorFlow is configured:docker run -it tensorflow/tensorflow bash
-v hostDir:containerDir -w workDir
parameter to load the server directory and change the container working directory as follows:docker run -it --rm -v $PWD:/tmp -w /tmp tensorflow/tensorflow python ./script.py
nightly
tag to start Jupyter laptop server:docker run -it -p 8888:8888 tensorflow/tensorflow:nightly-jupyter
docker run --gpus all -it --rm tensorflow/tensorflow:latest-gpu \\python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
docker exec
to use the container repeatedly.
Run the following command to use the latest TensorFlow GPU image to start the bash
shell session in the container:docker run --gpus all -it tensorflow/tensorflow:latest-gpu bash
Was this page helpful?