Skip to content

Commit

Permalink
Added better kernel searching for idempotency
Browse files Browse the repository at this point in the history
  • Loading branch information
simo-tuomisto committed Apr 8, 2021
1 parent ed5890b commit f1fefb7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
9 changes: 5 additions & 4 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
hosts: centos7_cuda_run
tasks:
- name: Check that NVIDIA kernel module has been installed
stat:
path: /lib/modules/{{ cuda_driver_kernel_version }}/video/nvidia.ko
register: nvidia_module_file
find:
path: /lib/modules/{{ cuda_driver_kernel_version }}
patterns: nvidia.ko
register: nvidia_module_find
- name: Verify that kernel module exists
assert:
that: nvidia_module_file.stat.exists
that: nvidia_module_find.matched > 0
24 changes: 17 additions & 7 deletions tasks/install_runfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
cuda_driver_kernel_version: "{{ cuda_driver_kernel_version | default(cuda_driver_kernel_running.stdout, true) }}"

- name: "Check NVIDIA kernel module"
stat:
path: /lib/modules/{{ cuda_driver_kernel_version }}/video/nvidia.ko
register: cuda_driver_kernel_module
find:
path: "/lib/modules/{{ cuda_driver_kernel_version }}"
patterns: nvidia.ko
recurse: true
register: cuda_driver_kernel_module_find

- name: "Check CUDA toolkit path"
stat:
Expand All @@ -43,9 +45,15 @@

- name: "Determine if driver and toolkit are installed"
set_fact:
cuda_driver_installed: "{{ cuda_driver_kernel_module.stat.exists }}"
cuda_driver_installed: "{{ cuda_driver_kernel_module_find.matched > 0 }}"
cuda_toolkit_installed: "{{ cuda_toolkit_path.stat.exists }}"

- name: "Print information about installed features"
debug:
msg:
- "Driver installed: {{ cuda_driver_installed }}"
- "Toolkit installed: {{ cuda_toolkit_installed }}"

- name: "Create temporary directory for runfile"
file:
path: /tmp/cuda_runfile
Expand Down Expand Up @@ -95,9 +103,11 @@
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 }} {{ "--no-drm" if cuda_runfile_disable_nvidia_drm else "" }}

when: cuda_runfile_driver and not cuda_driver_installed
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 "" }}
- name: "Install nvidia-persistenced systemd-file"
copy:
Expand Down

0 comments on commit f1fefb7

Please sign in to comment.