-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcuda_12_6_1_ubuntu_22.yaml
More file actions
84 lines (79 loc) · 2.99 KB
/
Copy pathcuda_12_6_1_ubuntu_22.yaml
File metadata and controls
84 lines (79 loc) · 2.99 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
######
###### Each of the comments before the Ansible blocks were pulled directly from https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=24.04&target_type=deb_local.
###### They indicate the step as suggested by NVIDIA. The blocks below adapt them into ansible configs.
######
# wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
# sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
- name: Setup CUDA repository pin
become: true
ansible.builtin.get_url:
url: https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
dest: /etc/apt/preferences.d/cuda-repository-pin-600
mode: '0444'
# wget https://developer.download.nvidia.com/compute/cuda/12.6.1/local_installers/cuda-repo-ubuntu2204-12-6-local_12.6.1-560.35.03-1_amd64.deb
- name: Download CUDA Repo
ansible.builtin.get_url:
url: https://developer.download.nvidia.com/compute/cuda/12.6.1/local_installers/cuda-repo-ubuntu2204-12-6-local_12.6.1-560.35.03-1_amd64.deb
dest: "{{ansible_env.HOME}}/installers/cuda-repo-ubuntu2204-12-6-local_12.6.1-560.35.03-1_amd64.deb"
mode: '0444'
checksum: sha256:129789e8d9ba2776e161d75c0e437f57adf666d7e9378d4892edefa99175b716
# sudo dpkg -i cuda-repo-ubuntu2204-12-6-local_12.6.1-560.35.03-1_amd64.deb
- name: Setup CUDA Repo
become: true
ansible.builtin.apt:
deb: "{{ansible_env.HOME}}/installers/cuda-repo-ubuntu2204-12-6-local_12.6.1-560.35.03-1_amd64.deb"
# sudo cp /var/cuda-repo-ubuntu2204-12-6-local/cuda-*-keyring.gpg /usr/share/keyrings/
- name: Add CUDA GPG APT key
become: true
ansible.builtin.copy:
src: /var/cuda-repo-ubuntu2204-12-6-local/cuda-D60B4864-keyring.gpg
dest: /usr/share/keyrings/
# sudo apt-get update
# sudo apt-get -y install cuda-toolkit-12-6
# sudo apt-get install -y nvidia-open
- name: Add CUDA Components
become: true
ansible.builtin.apt:
pkg:
- cuda-toolkit-12-6
- nvidia-driver-580-open # Upgrade to newer kernel version.
# - nvidia-open
state: latest
update_cache: true
# For GPU management. See https://askubuntu.com/questions/893528/restrict-user-access-to-gpu
- name: Create CUDA group
become: true
ansible.builtin.group:
name: cuda
state: present
gid: 65533
- name: Configure NVIDIA permissions
become: true
ansible.builtin.file:
path: '{{ item }}'
mode: '0770'
owner: root
group: cuda
loop:
- /dev/nvidia0
- /dev/nvidia1
- /dev/nvidia2
- /dev/nvidia3
- name: Set NVIDIA driver gid
become: true
community.general.modprobe:
name: nvidia
params: |
NVreg_DeviceFileGID=65533
NVreg_DeviceFileMode=0770
state: present
persistent: present
- name: Allow docker to use cuda
become: true
community.general.ini_file:
path: /etc/nvidia-container-runtime/config.toml
section: nvidia-container-cli
option: user
value: '"root:cuda"'
mode: '0644'
backup: true