Skip to content

Commit 02f50d2

Browse files
committed
check if its a GPU shape
1 parent de6a52f commit 02f50d2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
---
2+
- name: Check if its a GPU shape
3+
shell:
4+
cmd: "curl -sH \"Authorization: Bearer Oracle\" -L http://169.254.169.254/opc/v2/instance/ | jq .shape | grep GPU"
5+
warn: false
6+
register: shape
7+
failed_when: false
8+
9+
210
- name: Check if nvidia drivers are installed
311
shell: cat /sys/module/nvidia/version | wc -l
4-
register: gpu
12+
register: nvidia
13+
when: shape.stdout != ""
514

615

716
- name: Check if nvidia_peermem module is loaded
817
shell: lsmod | grep nvidia_peermem | wc -l
918
register: result
10-
when: gpu.stdout == '1'
19+
when: shape.stdout != "" and nvidia.stdout == '1'
1120

1221

1322
- name: Load nvidia_peermem module
1423
become: true
1524
shell: modprobe nvidia_peermem
16-
when: gpu.stdout == '1' and result.stdout != '3'
25+
when: shape.stdout != "" and nvidia.stdout == '1' and result.stdout != '3'

0 commit comments

Comments
 (0)