Skip to content

Instantly share code, notes, and snippets.

@zhiyue
Forked from dholt/nvidia-docker-2.yml
Created January 19, 2023 09:50
Show Gist options
  • Save zhiyue/eb9c77c339f050a05748aab856d60ada to your computer and use it in GitHub Desktop.
Save zhiyue/eb9c77c339f050a05748aab856d60ada to your computer and use it in GitHub Desktop.
Simple Ansible playbook for installing nvidia-docker-2 and setting it as the default runtime for Docker
- hosts: all
become: true
become_method: sudo
vars:
daemon_json:
bip: 192.168.99.1/24
default-runtime: nvidia
runtimes:
nvidia:
path: /usr/bin/nvidia-container-runtime
runtimeArgs: []
tasks:
- name: remove nvidia-docker v1
apt:
name: nvidia-docker
state: removed
purge: yes
- name: nvidia-docker | apt key
apt_key:
url: https://nvidia.github.io/nvidia-docker/gpgkey
state: present
- name: nvidia-docker | apt repo
apt_repository:
repo: "{{ item }}"
state: present
filename: 'nvidia-docker'
update_cache: yes
with_items:
- "deb https://nvidia.github.io/libnvidia-container/ubuntu16.04/amd64 /"
- "deb https://nvidia.github.io/nvidia-container-runtime/ubuntu16.04/amd64 /"
- "deb https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64 /"
- name: nvidia-docker | install
apt:
name: "{{ item }}"
state: present
with_items:
- "nvidia-docker2=2.0.2+docker17.03.2-1"
- "nvidia-container-runtime=1.1.1+docker17.03.2-1"
- name: set docker default runtime
copy:
content: "{{ daemon_json | to_nice_json }}"
dest: /etc/docker/daemon.json
owner: root
group: root
mode: 0644
- name: docker | restart service
service: name=docker state=restarted enabled=yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment