Skip to content

Commit

Permalink
Initial support for Debian
Browse files Browse the repository at this point in the history
  • Loading branch information
eric o meehan committed Aug 1, 2024
1 parent 8946eef commit f543f72
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 0 deletions.
27 changes: 27 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,33 @@ nvidia_driver_rhel_cuda_repo_gpgkey: "https://developer.download.nvidia.com/comp
nvidia_driver_rhel_branch: "{{ nvidia_driver_branch }}"


##############################################################################
# Debian
##############################################################################

# Driver branch to install with Debian
nvidia_driver_debian_branch: "{{ nvidia_driver_branch }}"

# Determine if we should install from CUDA repo instead of Canonical repos
nvidia_driver_debian_install_from_cuda_repo: no

# Installing with Debian repositories
nvidia_driver_debian_packages:
- "nvidia-driver"
- "nvidia-cuda-dev"
- "nvidia-cudaaaa-toolkit"

nvidia_driver_debian_install_tesla_driver: no
nvidia_driver_debian_tesla_package: "nvidia-tesla-470-driver"

# Installing with CUDA repositories
old_nvidia_driver_debian_cuda_repo_gpgkey_id: "7fa2af80"
nvidia_driver_debian_cuda_repo_baseurl: "https://developer.download.nvidia.com/compute/cuda/repos/{{ _debian_repo_dir }}"
nvidia_driver_debian_cuda_keyring_package: "cuda-keyring_1.1-1_all.deb"
nvidia_driver_debian_cuda_keyring_url: "{{ nvidia_driver_debian_cuda_repo_baseurl }}/{{ nvidia_driver_debian_cuda_keyring_package }}"
nvidia_driver_debian_cuda_package: "cuda-drivers-{{ nvidia_driver_debian_branch }}"


##############################################################################
# Ubuntu #
##############################################################################
Expand Down
50 changes: 50 additions & 0 deletions tasks/install-debian-cuda-repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
- name: add contrib & non-free repository
replace:
dest: /etc/apt/sources.list
regexp: '^(deb(?!.* contrib).*)'
replace: '\1 contrib non-free'

- name: remove old signing key
apt_key:
id: "{{ old_nvidia_driver_debian_cuda_repo_gpgkey_id }}"
state: absent
environment: "{{proxy_env if proxy_env is defined else {}}}"
when: nvidia_driver_add_repos | bool

- name: add CUDA keyring
apt:
deb: "{{ nvidia_driver_debian_cuda_keyring_url }}"
state: "present"
environment: "{{proxy_env if proxy_env is defined else {}}}"
when: nvidia_driver_add_repos | bool

- name: force an apt update
apt:
update_cache: true
changed_when: false

- name: ensure kmod is installed
apt:
name: "kmod"
state: "present"

- name: blacklist nouveau
kernel_blacklist:
name: nouveau
state: present

- name: install Linux headers and non-free firmware
apt:
name:
- linux-headers-{{ ansible_kernel }}
- firmware-misc-nonfree
state: present

- name: install driver packages
apt:
name: "{{ nvidia_driver_package_version | ternary(nvidia_driver_debian_cuda_package+'='+nvidia_driver_package_version, nvidia_driver_debian_cuda_package) }}"
state: "{{ nvidia_driver_package_state }}"
autoremove: "{{ nvidia_driver_package_state == 'absent' }}"
purge: "{{ nvidia_driver_package_state == 'absent' }}"
register: install_driver
environment: "{{proxy_env if proxy_env is defined else {}}}"
35 changes: 35 additions & 0 deletions tasks/install-debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
- name: add contrib & non-free repository
replace:
dest: /etc/apt/sources.list
regexp: '^(deb(?!.* contrib).*)'
replace: '\1 contrib non-free'

- name: update apt
become: yes
apt:
update_cache: yes

- name: install Linux headers and non-free firmware
apt:
name:
- linux-headers-{{ ansible_kernel }}
- firmware-misc-nonfree
state: present

- name: install driver packages
apt:
name: "{{ nvidia_driver_package_version | ternary(item+'='+nvidia_driver_package_version, item) }}"
state: "{{ nvidia_driver_package_state }}"
autoremove: "{{ nvidia_driver_package_state == 'absent' }}"
purge: "{{ nvidia_driver_package_state == 'absent' }}"
loop: "{{ nvidia_driver_debian_packages }}"
register: install_driver
environment: "{{proxy_env if proxy_env is defined else {}}}"

- name: install tesla drivers
apt:
state: present
name: "{{ nvidia_driver_debian_tesla_package }}"
register: install_driver
when: nvidia_driver_debian_install_tesla_driver == true
8 changes: 8 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
state: absent
ignore_errors: true

- name: debian install tasks (debian repos)
include_tasks: install-debian.yml
when: ansible_distribution == "Debian" and (not nvidia_driver_debian_install_from_cuda_repo)

- name: debian install tasks (CUDA repos)
include_tasks: install-debian.yml
when: ansible_distribution == "Debian" and nvidia_driver_debian_install_from_cuda_repo

- name: ubuntu install tasks (canonical repos)
include_tasks: install-ubuntu.yml
when: ansible_distribution == 'Ubuntu' and (not nvidia_driver_ubuntu_install_from_cuda_repo)
Expand Down
1 change: 1 addition & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
_debian_repo_dir: "{{ ansible_distribution | lower }}{{ ansible_distribution_version | replace('.', '') }}/{{ ansible_architecture }}"
_ubuntu_repo_dir: "{{ ansible_distribution | lower }}{{ ansible_distribution_version | replace('.', '') }}/{{ ansible_architecture }}"
_rhel_repo_dir: "rhel{{ ansible_distribution_major_version }}/{{ ansible_architecture }}"

0 comments on commit f543f72

Please sign in to comment.