Skip to content

Commit

Permalink
Allow disabling nvidia-drm-module, copying runfile from files and ena…
Browse files Browse the repository at this point in the history
…bling nvidia-persistenced-service
  • Loading branch information
simo-tuomisto committed Apr 7, 2021
1 parent 73eda0f commit b32cba8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ cuda_use_runfile: False
cuda_runfile_url: "https://developer.download.nvidia.com/compute/cuda/11.2.2/local_installers/cuda_11.2.2_460.32.03_linux.run"
cuda_runfile_driver: True
cuda_runfile_toolkit: True
cuda_runfile_download: True
cuda_runfile_remove: True
cuda_runfile_disable_nvidia_drm: False
cuda_restart_node_on_install: True
cuda_init: True
cuda_init_restart_service: True
Expand Down
14 changes: 14 additions & 0 deletions files/nvidia-persistenced.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=NVIDIA Persistence Daemon
After=syslog.target

[Service]
Type=forking
PIDFile=/var/run/nvidia-persistenced/nvidia-persistenced.pid
Restart=always
ExecStart=/usr/bin/nvidia-persistenced --verbose
ExecStopPost=/bin/rm -rf /var/run/nvidia-persistenced/*
TimeoutSec=300

[Install]
WantedBy=multi-user.target
34 changes: 26 additions & 8 deletions tasks/install_runfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,24 @@
path: /tmp/cuda_runfile
state: directory

- name: "Download runfile"
get_url:
url: "{{ cuda_runfile_url }}"
dest: "/tmp/cuda_runfile/{{ cuda_runfile_sh }}"
- name: "Obtain runfile"
block:

- name: "Copy pre-downloaded runfile"
copy:
src: "{{ cuda_runfile_sh }}"
dest: /tmp/cuda_runfile
when: not cuda_runfile_download

- name: "Download runfile"
get_url:
url: "{{ cuda_runfile_url }}"
dest: "/tmp/cuda_runfile/{{ cuda_runfile_sh }}"
when: cuda_runfile_download

when: (cuda_runfile_toolkit and not cuda_toolkit_installed) or
(cuda_runfile_driver and not cuda_driver_installed)


- name: "Run installer for toolkit"
command: bash /tmp/cuda_runfile/{{ cuda_runfile_sh }} --silent --toolkit
register: cuda_toolkit_install_out
Expand All @@ -85,12 +95,20 @@
msg: "Building driver {{ cuda_driver_runfile }} for kernel {{ cuda_driver_kernel_version }}"

- name: 'Install driver'
command: bash {{ cuda_driver_runfile }} --silent --kernel-name={{ cuda_driver_kernel_version }} --kernel-source-path=/usr/src/kernels/{{ cuda_driver_kernel_version }}
command: bash {{ cuda_driver_runfile }} --silent --kernel-name={{ cuda_driver_kernel_version }} --kernel-source-path=/usr/src/kernels/{{ cuda_driver_kernel_version }} {{ '--no-drm' if cuda_runfile_disable_nvidia_drm else '' }}

when: cuda_runfile_driver and not cuda_driver_installed

- name: "Install nvidia-persistenced systemd-file"
copy:
src: files/nvidia-persistenced.service
dest: /etc/systemd/system/nvidia-persistenced.service
when: cuda_init_persistence_mode | bool

when: cuda_runfile_driver and not cuda_driver_installed

- name: 'Remove installer'
- name: "Remove installer"
file:
path: /tmp/cuda_runfile
state: absent
when: and cuda_runfile_remove
when: cuda_runfile_remove

0 comments on commit b32cba8

Please sign in to comment.