Skip to content

Commit 621f4ca

Browse files
committed
install cuda packages directly from module info
1 parent 56ceece commit 621f4ca

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

ansible/roles/cuda/tasks/install.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,21 @@
2929
when: "'No matching Modules to list' in _cuda_driver_module_enabled.stderr"
3030
changed_when: "'Nothing to do' not in _cuda_driver_module_enable.stdout"
3131

32-
- name: Check if nvidia driver module is installed
33-
ansible.builtin.command: dnf module list --installed nvidia-driver
32+
- name: Read module info for list of packages
33+
ansible.builtin.shell:
34+
cmd: >-
35+
dnf module info nvidia-driver:{{ cuda_nvidia_driver_stream }} |
36+
grep {{ cuda_nvidia_driver_version }}.el{{ ansible_distribution_major_version }}.{{ ansible_architecture }}
3437
changed_when: false
35-
failed_when: false
36-
register: _cuda_driver_module_installed
38+
register: _cuda_driver_module_packages
39+
# returns a list of lines like ' : libnvidia-cfg-3:570.133.20-1.el9.x86_64'
3740

38-
- name: Install nvidia drivers
39-
ansible.builtin.command: "dnf module install -y nvidia-driver-{{ cuda_nvidia_driver_version}}"
41+
- name: Install nvidia driver packages
42+
ansible.builtin.dnf:
43+
name: "{{ _cuda_driver_module_packages.stdout_lines | map('trim', ': ') }}"
4044
register: _cuda_driver_install
41-
when: "'No matching Modules to list' in _cuda_driver_module_installed.stderr"
42-
changed_when: "'Nothing to do' not in _cuda_driver_install.stdout"
45+
46+
- meta: end_here
4347

4448
- name: Check kernel has not been modified
4549
assert:

0 commit comments

Comments
 (0)