v1.3
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
- name: Detect WSL
|
||||
- name: Classify supported host profile
|
||||
set_fact:
|
||||
courseware_is_macos: "{{ ansible_system == 'Darwin' }}"
|
||||
courseware_is_linux: "{{ ansible_system == 'Linux' }}"
|
||||
courseware_is_wsl: "{{ 'microsoft' in ansible_kernel | lower or 'wsl' in ansible_kernel | lower }}"
|
||||
courseware_is_native_linux: "{{ ansible_system == 'Linux' and not ('microsoft' in ansible_kernel | lower or 'wsl' in ansible_kernel | lower) }}"
|
||||
courseware_host_profile: "{{ 'macos' if ansible_system == 'Darwin' else ('wsl' if ('microsoft' in ansible_kernel | lower or 'wsl' in ansible_kernel | lower) else ('native-debian-ubuntu' if ansible_system == 'Linux' and ansible_os_family == 'Debian' else 'unsupported')) }}"
|
||||
|
||||
- name: Fail on unsupported operating systems
|
||||
fail:
|
||||
@@ -52,7 +56,7 @@
|
||||
fail:
|
||||
msg: "This installer currently supports Debian and Ubuntu only."
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_linux
|
||||
- ansible_os_family != "Debian"
|
||||
|
||||
- name: Query NVIDIA GPU memory
|
||||
@@ -60,27 +64,27 @@
|
||||
register: courseware_gpu_memory
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when: ansible_system == "Linux"
|
||||
when: courseware_is_linux
|
||||
|
||||
- name: Query NVIDIA GPU names
|
||||
command: nvidia-smi --query-gpu=name --format=csv,noheader
|
||||
register: courseware_gpu_names
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when: ansible_system == "Linux"
|
||||
when: courseware_is_linux
|
||||
|
||||
- name: Fail when no supported NVIDIA GPU is visible
|
||||
fail:
|
||||
msg: "Linux/WSL requires an NVIDIA GPU visible to nvidia-smi."
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_linux
|
||||
- courseware_gpu_memory.rc != 0
|
||||
|
||||
- name: Fail when GPU VRAM is below baseline
|
||||
fail:
|
||||
msg: "This build assumes at least 8 GB of VRAM on Linux/WSL."
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_linux
|
||||
- (courseware_gpu_memory.stdout_lines | map('int') | max) < 8192
|
||||
|
||||
- name: Check for CUDA compiler on Linux
|
||||
@@ -88,7 +92,23 @@
|
||||
register: courseware_preflight_nvcc
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when: ansible_system == "Linux"
|
||||
when: courseware_is_linux
|
||||
|
||||
- name: Check for CUDA compiler in standard install locations
|
||||
shell: |
|
||||
for candidate in /usr/local/cuda/bin/nvcc /usr/local/cuda-*/bin/nvcc; do
|
||||
if [ -x "$candidate" ]; then
|
||||
printf '%s\n' "$candidate"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
exit 1
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: courseware_preflight_nvcc_fallback
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when: courseware_is_linux
|
||||
|
||||
- name: Check for CUDA runtime header on Linux
|
||||
stat:
|
||||
@@ -97,16 +117,17 @@
|
||||
- /usr/local/cuda/include/cuda_runtime.h
|
||||
- /usr/include/cuda_runtime.h
|
||||
register: courseware_preflight_cuda_headers
|
||||
when: ansible_system == "Linux"
|
||||
when: courseware_is_linux
|
||||
|
||||
- name: Set CUDA toolkit readiness
|
||||
set_fact:
|
||||
courseware_cuda_toolkit_ready: >-
|
||||
{{
|
||||
courseware_preflight_nvcc.rc == 0
|
||||
or courseware_preflight_nvcc_fallback.rc == 0
|
||||
or (courseware_preflight_cuda_headers.results | selectattr('stat.exists', 'equalto', true) | list | length > 0)
|
||||
}}
|
||||
when: ansible_system == "Linux"
|
||||
when: courseware_is_linux
|
||||
|
||||
- name: Query distro CUDA toolkit apt candidate
|
||||
command: apt-cache policy nvidia-cuda-toolkit
|
||||
@@ -114,7 +135,7 @@
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_linux
|
||||
- ansible_os_family == "Debian"
|
||||
|
||||
- name: Set distro CUDA toolkit package availability
|
||||
@@ -125,15 +146,14 @@
|
||||
and 'Candidate: (none)' not in courseware_preflight_cuda_toolkit_policy.stdout
|
||||
}}
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_linux
|
||||
- ansible_os_family == "Debian"
|
||||
|
||||
- name: Fail when automatic WSL CUDA bootstrap is unsupported
|
||||
fail:
|
||||
msg: "Automatic CUDA bootstrap currently supports Ubuntu x86_64 on WSL only. For other WSL distros, install the CUDA toolkit manually before rerunning."
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_wsl
|
||||
- courseware_host_profile == "wsl"
|
||||
- not courseware_cuda_toolkit_ready
|
||||
- ansible_distribution != "Ubuntu" or ansible_architecture not in ["x86_64", "amd64"]
|
||||
|
||||
@@ -144,8 +164,7 @@
|
||||
state: present
|
||||
update_cache: true
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_wsl
|
||||
- courseware_host_profile == "wsl"
|
||||
- not courseware_cuda_toolkit_ready
|
||||
- ansible_distribution == "Ubuntu"
|
||||
- ansible_architecture in ["x86_64", "amd64"]
|
||||
@@ -157,8 +176,7 @@
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_wsl
|
||||
- courseware_host_profile == "wsl"
|
||||
- not courseware_cuda_toolkit_ready
|
||||
- ansible_distribution == "Ubuntu"
|
||||
- ansible_architecture in ["x86_64", "amd64"]
|
||||
@@ -172,8 +190,7 @@
|
||||
- /usr/include/cuda_runtime.h
|
||||
register: courseware_preflight_cuda_headers_after_distro_install
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_wsl
|
||||
- courseware_host_profile == "wsl"
|
||||
- not courseware_cuda_toolkit_ready
|
||||
- ansible_distribution == "Ubuntu"
|
||||
- ansible_architecture in ["x86_64", "amd64"]
|
||||
@@ -187,8 +204,7 @@
|
||||
or (courseware_preflight_cuda_headers_after_distro_install.results | selectattr('stat.exists', 'equalto', true) | list | length > 0)
|
||||
}}
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_wsl
|
||||
- courseware_host_profile == "wsl"
|
||||
- not courseware_cuda_toolkit_ready
|
||||
- ansible_distribution == "Ubuntu"
|
||||
- ansible_architecture in ["x86_64", "amd64"]
|
||||
@@ -201,8 +217,7 @@
|
||||
changed_when: courseware_wsl_cuda_apt_key_delete.rc == 0
|
||||
failed_when: false
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_wsl
|
||||
- courseware_host_profile == "wsl"
|
||||
- not courseware_cuda_toolkit_ready
|
||||
- ansible_distribution == "Ubuntu"
|
||||
- ansible_architecture in ["x86_64", "amd64"]
|
||||
@@ -215,8 +230,7 @@
|
||||
mode: "0644"
|
||||
force: true
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_wsl
|
||||
- courseware_host_profile == "wsl"
|
||||
- not courseware_cuda_toolkit_ready
|
||||
- ansible_distribution == "Ubuntu"
|
||||
- ansible_architecture in ["x86_64", "amd64"]
|
||||
@@ -228,8 +242,7 @@
|
||||
mode: "0644"
|
||||
force: false
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_wsl
|
||||
- courseware_host_profile == "wsl"
|
||||
- not courseware_cuda_toolkit_ready
|
||||
- ansible_distribution == "Ubuntu"
|
||||
- ansible_architecture in ["x86_64", "amd64"]
|
||||
@@ -240,8 +253,7 @@
|
||||
deb: "{{ courseware_wsl_cuda_installer_local_path }}"
|
||||
state: present
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_wsl
|
||||
- courseware_host_profile == "wsl"
|
||||
- not courseware_cuda_toolkit_ready
|
||||
- ansible_distribution == "Ubuntu"
|
||||
- ansible_architecture in ["x86_64", "amd64"]
|
||||
@@ -254,8 +266,7 @@
|
||||
file_type: file
|
||||
register: courseware_wsl_cuda_keyring
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_wsl
|
||||
- courseware_host_profile == "wsl"
|
||||
- not courseware_cuda_toolkit_ready
|
||||
- ansible_distribution == "Ubuntu"
|
||||
- ansible_architecture in ["x86_64", "amd64"]
|
||||
@@ -264,8 +275,7 @@
|
||||
fail:
|
||||
msg: "The NVIDIA WSL CUDA repository package was installed, but its keyring file was not found under {{ courseware_wsl_cuda_repo_dir }}."
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_wsl
|
||||
- courseware_host_profile == "wsl"
|
||||
- not courseware_cuda_toolkit_ready
|
||||
- ansible_distribution == "Ubuntu"
|
||||
- ansible_architecture in ["x86_64", "amd64"]
|
||||
@@ -279,8 +289,7 @@
|
||||
remote_src: true
|
||||
mode: "0644"
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_wsl
|
||||
- courseware_host_profile == "wsl"
|
||||
- not courseware_cuda_toolkit_ready
|
||||
- ansible_distribution == "Ubuntu"
|
||||
- ansible_architecture in ["x86_64", "amd64"]
|
||||
@@ -293,8 +302,7 @@
|
||||
state: present
|
||||
update_cache: true
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_wsl
|
||||
- courseware_host_profile == "wsl"
|
||||
- not courseware_cuda_toolkit_ready
|
||||
- ansible_distribution == "Ubuntu"
|
||||
- ansible_architecture in ["x86_64", "amd64"]
|
||||
@@ -305,8 +313,7 @@
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_wsl
|
||||
- courseware_host_profile == "wsl"
|
||||
- not courseware_cuda_toolkit_ready
|
||||
- ansible_distribution == "Ubuntu"
|
||||
- ansible_architecture in ["x86_64", "amd64"]
|
||||
@@ -315,8 +322,7 @@
|
||||
fail:
|
||||
msg: "The NVIDIA WSL CUDA toolkit install completed, but `nvcc` is still missing. Verify the repository package and rerun the installer."
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_is_wsl
|
||||
- courseware_host_profile == "wsl"
|
||||
- not courseware_cuda_toolkit_ready
|
||||
- ansible_distribution == "Ubuntu"
|
||||
- ansible_architecture in ["x86_64", "amd64"]
|
||||
|
||||
Reference in New Issue
Block a user