-
Install Docker (see https://gist.github.com/vicente-gonzalez-ruiz/cfa615abea6172f266180760fc4fba93 and https://gist.github.com/vicente-gonzalez-ruiz/fa3c7724750ec0837818ad8b337bba50).
rm -r $HOME/.docker/desktop sudo rm /usr/local/bin/com.docker.cli sudo apt purge docker-desktop
sudo apt-get update sudo apt-get install ca-certificates curl gnupg sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu
$(. /etc/os-release && echo "$VERSION_CODENAME") 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-buildx-plugin docker-compose-plugin -
(Optional, only if you have an Nvidia GPU) Install a NVIDIA driver (see https://gist.github.com/vicente-gonzalez-ruiz/eb75332ac1b16d96224ec71cd94d7763).
-
Install a Tensorflow container: sudo docker pull tensorflow/tensorflow:2.14.0-jupyter # No GPU, jupyter
-
Run the container: sudo docker run -it --rm -v $(realpath ~/notebooks):/tf/notebooks -p 8888:8888 tensorflow/tensorflow:2.14.0-jupyter
-
(Optional, only if you have an Nvidia GPU) Install the NVIDIA Container Toolkit (for GPU support) (see https://github.com/NVIDIA/nvidia-docker):
- Setup the package repository and the GPG key:
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
- Test:
# Check nvidia-smi from Docker: docker run --rm --gpus all nvidia/cuda:11.6.2-base-ubuntu20.04 nvidia-smi # Run minimal TensorFlow code which uses the GPU from Docker: 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])))"
Last active
December 20, 2023 16:54
-
-
Save vicente-gonzalez-ruiz/afa3c8f9664c660904eaa728c37b6576 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment