Skip to content

Commit

Permalink
Define resource to stop nvidia services
Browse files Browse the repository at this point in the history
  • Loading branch information
cmd-ntrf committed Jan 23, 2025
1 parent 13077f0 commit baa8eca
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions site/profile/manifests/gpu.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,23 @@
group => 'root',
mode => '0755',
}

file_line { 'nvidia_restrict_profiling':
path => '/etc/modprobe.d/nvidia.conf',
match => '^options nvidia NVreg_RestrictProfilingToAdminUsers',
line => "options nvidia NVreg_RestrictProfilingToAdminUsers=${Integer($restrict_profiling)}",
require => File['/etc/modprobe.d/nvidia.conf'],
notify => [
Exec['unload nvidia drivers'],
Exec['stop_nvidia_services'],
Exec['unload_nvidia_drivers'],
],
}
exec { 'unload nvidia drivers':

exec { 'unload_nvidia_drivers':
command => sprintf('rmmod %s', $nvidia_kmod.reverse.join(' ')),
onlyif => 'grep -qE "^nvidia " /proc/modules',
refreshonly => true,
require => Exec['stop_nvidia_services'],
notify => Kmod::Load[$nvidia_kmod],
path => ['/bin', '/sbin'],
}
Expand Down Expand Up @@ -90,6 +94,7 @@
Package<| tag == profile::gpu::install |> ~> Exec['nvidia-symlink']
Exec<| tag == profile::gpu::install::vgpu::bin |> ~> Exec['nvidia-symlink']
}
Kmod::Load[$nvidia_kmod] ~> Service<| tag == profile::gpu::services |>
}

class profile::gpu::install::passthrough (
Expand Down Expand Up @@ -322,6 +327,13 @@
enable => true,
}

exec { 'stop_nvidia_services':
command => sprintf('systemctl stop %s', $gpu_services.reverse.join(' ')),
onlyif => sprintf('systemctl is-active %s', $gpu_services.reverse.join(' ')),
refreshonly => true,
path => ['/usr/bin'],
}

Package<| tag == profile::gpu::install |> -> Service[$gpu_services]
Exec<| tag == profile::gpu::install::vgpu::bin |> -> Exec[$gpu_services]
}

0 comments on commit baa8eca

Please sign in to comment.