This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 549
/
main.yml
60 lines (54 loc) · 1.81 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
- name: "Check GPU card info with lspci"
raw: "lspci | grep -E '[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F].[0-9] (3D|VGA compatible) controller: NVIDIA Corporation.*'"
register: lspci_grep
failed_when: false
changed_when: false
check_mode: false
environment: {}
- name: "Check NVIDIA GPU exits or not"
set_fact:
unmet_requirements: "{{ unmet_requirements + ['NVIDIA GPU card is not detected'] }}"
changed_when: false
check_mode: false
environment: {}
when:
- lspci_grep.rc != 0
- name: "Check NVIDIA GPU drivers with nvidia-smi"
raw: "nvidia-smi"
register: nvidia_smi
failed_when: false
changed_when: false
check_mode: false
environment: {}
- name: "Check NVIDIA GPU drivers is installed or not "
set_fact:
unmet_requirements: "{{ unmet_requirements + ['NVIDIA GPU drivers is not detected'] }}"
changed_when: false
check_mode: false
environment: {}
when:
- nvidia_smi.rc != 0
- name: "Check NVIDIA GPU card number with nvidia-smi"
raw: "nvidia-smi --query-gpu=gpu_name --format=csv | tail --lines=+2 | wc -l"
register: nvidia_gpu_count
failed_when: false
changed_when: false
check_mode: false
environment: {}
when:
# if nvidia-smi doesn't work, we can skip this step
- nvidia_smi.rc == 0
- name: "Check NVIDIA GPU card number is matched or not"
set_fact:
unmet_requirements: "{{ unmet_requirements + [\"NVIDIA GPU card number is not matched: {{ computing_device_count }} specified but {{ nvidia_gpu_count.stdout|trim }} found\"] }}"
changed_when: false
check_mode: false
environment: {}
when:
# if nvidia-smi doesn't work, we can skip this step
- nvidia_smi.rc == 0
- 'nvidia_gpu_count.stdout|trim|int != computing_device_count'
- nvidia_gpu_count.rc == 0
- name: "Check default docker runtime"
include_tasks: docker-runtime.yml