This commit is contained in:
Alwin Berger 2024-07-10 13:21:57 +02:00
commit 82b93ed872
3 changed files with 76 additions and 0 deletions

20
README.md Normal file
View File

@ -0,0 +1,20 @@
# NVIDIA + Podman
This role installs the NVIDIA drivers (from non-free), container toolkit (NVIDIAs repo) and podman on a debian (bookworm) system.
# License
```
Zero-Clause BSD
=============
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
```
# Author Information
Alwin Berger, Informatik 12, TU Dortmund, alwin.berger@udo.edu

6
handlers/main.yaml Normal file
View File

@ -0,0 +1,6 @@
---
- name: 'apt update'
ansible.builtin.apt:
update_cache: yes
environment:
NEEDRESTART_SUSPEND: 'please no reboot now'

50
tasks/main.yaml Normal file
View File

@ -0,0 +1,50 @@
---
- name: Add 'contrib' and 'non-free' repository in /etc/apt/sources.list
lineinfile:
path: /etc/apt/sources.list
regexp: '^deb\s+(.*)/debian/\s+bookworm\s+(.*)firmware$'
line: 'deb \1/debian/ bookworm \2firmware contrib non-free'
backrefs: yes
state: present
notify:
- apt update
- name: Install nvidia drivers
apt:
name: [ 'linux-headers-amd64', 'nvidia-driver', 'firmware-misc-nonfree' ]
# https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html
- name: Install nvidia-container-toolkit
block:
- name: libnvidia-container | no apt key
ansible.builtin.get_url:
url: https://nvidia.github.io/libnvidia-container/gpgkey
dest: /usr/share/keyrings/nvidia-container-toolkit-keyring.asc
checksum: sha256:c880576d6cf75a48e5027a871bac70fd0421ab07d2b55f30877b21f1c87959c9
- name: libnvidia-container | dearmor key
ansible.builtin.command: gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg /usr/share/keyrings/nvidia-container-toolkit-keyring.asc
args:
creates: /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
- name: libnvidia-container | apt source
ansible.builtin.apt_repository:
repo: "deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://nvidia.github.io/libnvidia-container/stable/deb/$(ARCH) /"
state: present
notify:
- apt update
- name: libnvidia-container | install nvidia-container-toolkit
apt:
name: ['nvidia-container-toolkit']
# https://docs.nvidia.com/ai-enterprise/deployment-guide-rhel-with-kvm/0.1.0/podman.html
# https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/cdi-support.html
- name: libnvidia-container | cdi
ansible.builtin.command: sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml
args:
creates: /etc/cdi/nvidia.yaml
- name: Install podman
apt:
name: [ 'podman', 'podman-compose' ]