Skip to content

Commit

Permalink
F #src 7235 updating nvidia container toolkit (#557)
Browse files Browse the repository at this point in the history
* Update nvidia-container-toolkit.yml

* Update nvidia-container-toolkit.yml

* Update nvidia-container-toolkit.yml

* Update nvidia-container-toolkit.yml

* Update nvidia-container-toolkit.yml

* Update nvidia-container-toolkit.yml

* Update main.yml

* Update nvidia-container-toolkit.yml

* Update main.yml

* Update nvidia-container-toolkit.yml

* Update nvidia-container-toolkit.yml

* Update nvidia-container-toolkit.yml
  • Loading branch information
carebare47 authored and carebare47 committed Sep 4, 2023
1 parent 8011dcc commit eeecfcb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 48 deletions.
23 changes: 15 additions & 8 deletions ansible/roles/installation/nvidia-docker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,22 @@
state: present
become: yes

- name: query prime-select
command: prime-select query
become: yes
register: prime_select_results
- name: Query and set prime-select
block:
- name: query prime-select
command: prime-select query
become: yes
register: prime_select_results

- name: switch driver to nvidia
command: prime-select nvidia
become: yes
when: "prime_select_results.stdout != 'nvidia'"
- name: switch driver to nvidia
command: prime-select nvidia
become: yes
when: "prime_select_results.stdout != 'nvidia'"

- name: query prime-select again, check it's been set
command: prime-select query
become: yes
register: prime_select_results

- name: end playbook so user can reboot
fail:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,28 @@
name: nvidia-modprobe
state: present

- name: Install nvidia-docker gpg key
apt_key:
url: https://nvidia.github.io/nvidia-docker/gpgkey
state: present

- name: Set ubuntu_version to 18.04 for nvidia-container-toolkit install
set_fact:
ubuntu_version: "18.04"
when:
- ansible_distribution|string == 'Ubuntu'
- ansible_distribution_release|string == 'bionic'

- name: Set ubuntu_version to 20.04 for nvidia-container-toolkit install
set_fact:
ubuntu_version: "20.04"
when:
- ansible_distribution|string == 'Ubuntu'
- ansible_distribution_release|string == 'focal'

- name: Set ubuntu_version to 22.04 for nvidia-container-toolkit install
set_fact:
ubuntu_version: "22.04"
when:
- ansible_distribution|string == 'Ubuntu'
- ansible_distribution_release|string == 'jammy'

- name: Add nvidia-docker repository
apt_repository:
repo: deb https://nvidia.github.io/{{ item }}/ubuntu{{ ubuntu_version }}/amd64 /
state: present
with_items:
- nvidia-docker

- name: Add libnvidia-container repository
apt_repository:
repo: deb https://nvidia.github.io/{{ item }}/stable/ubuntu{{ ubuntu_version }}/amd64 /
state: present
with_items:
- libnvidia-container
- nvidia-container-runtime
- name: Check nvidia-container-toolkit repository key exists
stat:
path: /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
register: nvidia_container_toolkit_repo_key_exists

# Inspired by: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#setting-up-nvidia-container-toolkit
- name: Get and de-armour gpg key, add repository
block:
- name: Get armoured gpg key
ansible.builtin.get_url:
url: https://nvidia.github.io/libnvidia-container/gpgkey
dest: /tmp/nvidia-container-toolkit-keyring.asc

- name: Dearmour gpg key
shell: cat /tmp/nvidia-container-toolkit-keyring.asc | gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
become: true

- name: Add nvidia-container-toolkit repository, pointing to the dearmored gpg key (backwards compatable, 18.04 should work with up to at least 22.04)
ansible.builtin.apt_repository:
repo: "deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/$(ARCH) /"
state: present
when: nvidia_container_toolkit_repo_key_exists.stat.exists == false

- name: Install nvidia-container-toolkit
apt:
Expand Down

0 comments on commit eeecfcb

Please sign in to comment.