How To: Use TensorFlow GPU enabled Docker

vahid_jani
1 min readSep 11, 2020

This process is tested on Ubuntu

Follow this steps :

  1. Install Docker in your system
  2. Be sure to have NVIDIA driver installed
  3. Setting up NVIDIA Container Toolkit (src: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker):

for now(11.01.2023) it is a s followed but always use the updated official instruction from above link:

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

followed by:

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

4. check it by pulling this image from hub (check docker hub website for the latest image) :

sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi

5. Now its time to pull an appropriate image for tensor flow GPU capable with connection to a folder in our local drive to work on :

--

--