Skip to content

Instantly share code, notes, and snippets.

@torhans
Last active April 7, 2020 22:17
Show Gist options
  • Save torhans/a6a7591f2b7c97851761d6c47eb8643a to your computer and use it in GitHub Desktop.
Save torhans/a6a7591f2b7c97851761d6c47eb8643a to your computer and use it in GitHub Desktop.
#add yourself to docker group and _reboot_ or _login again_
sudo zypper ar https://download.opensuse.org/repositories/Virtualization:/containers/openSUSE_Leap_15.1/Virtualization:containers.repo
sudo zypper install --allow-vendor-change 'docker >= 19.03'
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
sudo zypper ar https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.repo
sudo zypper install nvidia-container-toolkit
# -y has been remove relative to guide at https://github.com/NVIDIA/nvidia-docker
sudo systemctl restart docker
# test docker and nvidia installation
docker run --gpus all nvidia/cuda:10.0-base nvidia-smi
# make docker start at boot up
sudo systemctl enable docker
# pull tensorflow docker image
docker pull tensorflow/tensorflow:latest-gpu-py3-jupyter
# prepare user systemd config localation
mkdir -p .config/systemd/user
cat << EOF > .config/systemd/user/tensorflow.service
[Unit]
Description=tensorflow container
Requires=docker
After=docker
# create the service file
# change /home/user to correct folder
[Service]
ExecStart=/usr/bin/docker run --gpus all -u 1000:100 -p 8889:8888 --name tensorflow-docker --mount type=bind,source=/home/user/tensorflow/config,target=/.jupyter --mount type=bind,source=/home/user/tensorflow/local,target=/.local --mount type=bind,source=/home/user/tensorflow/cache,target=/.cache --mount type=bind,source=/home/user/tensorflow/notebooks,target=/tf/notebooks tensorflow/tensorflow:latest-gpu-py3-jupyter
ExecStop=/usr/bin/docker stop -t 2 tensorflow-docker
ExecStopPost=/usr/bin/docker rm -f tensorflow-docker
[Install]
WantedBy=local.target
EOF
# make the service start a login
systemctl --user enable tensorflow
# run the service without login (not testet)
# sudo loginctl enable-linger $(whoami)
# https://wiki.archlinux.org/index.php/Systemd/User#Automatic_start-up_of_systemd_user_instances
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment