Skip to content

Commit

Permalink
for issue #2 - let's set persistence and compute mode on boot
Browse files Browse the repository at this point in the history
  • Loading branch information
martbhell committed Apr 27, 2016
1 parent 60a5f1b commit 1b7f433
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ Role Variables
--------------

<pre>
gpu: True
cuda_packages:
- "cuda"
</pre>

This list can be updated to include more packages that are installed after nvidia cuda repo is installed.
- gpu: True is needed. Without it this role does nothing.
- cuda_packages: List that can be updated to include more packages that are installed after nvidia cuda repo is installed.
- cuda_init: Installs a bash script that is executed via rc.local on boot




Dependencies
Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ cuda_repo_url: "http://developer.download.nvidia.com/compute/cuda/repos/"
cuda_packages:
- "cuda"
cuda_restart_node_on_install: True
cuda_init: True
cuda_init_compute_mode: 3
cuda_init_persistence_mode: 1
15 changes: 15 additions & 0 deletions tasks/redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,18 @@
notify:
- ZZ CUDA Restart server
- ZZ CUDA Wait for server to restart

- name: template in cuda_init.sh used during boot
template: src=cuda_init.sh.j2
dest=/usr/local/bin/cuda_init.sh
owner=root group=root mode=0755
backup=no
when: cuda_init

- name: add the cuda_init.sh script to rc.local
lineinfile:
dest=/etc/rc.local
insertafter=EOF
regexp="^/bin/bash /usr/local/bin/cuda_init.sh$"
line="/bin/bash /usr/local/bin/cuda_init.sh"
when: cuda_init
9 changes: 9 additions & 0 deletions templates/cuda_init.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# During boot we initialize the GPUs (creates /dev/nvidia*)

if [ ! -f "/usr/bin/nvidia-smi" ]; then
logger -s -t nvidia-smi "Script $0 could not find /usr/bin/nvidia-smi"
else
/usr/bin/nvidia-smi --compute-mode={{ cuda_init_compute_mode }}
/usr/bin/nvidia-smi --persistence-mode={{ cuda_init_persistence_mode }}
fi

0 comments on commit 1b7f433

Please sign in to comment.