v1.3
This commit is contained in:
@@ -12,6 +12,22 @@
|
||||
failed_when: false
|
||||
when: ansible_system == "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_llama_nvcc_fallback
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when: ansible_system == "Linux"
|
||||
|
||||
- name: Check for CUDA runtime header on Linux
|
||||
stat:
|
||||
path: "{{ item }}"
|
||||
@@ -48,24 +64,63 @@
|
||||
ls /usr/local/cuda/include/cuda_runtime.h
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_llama_nvcc.rc != 0 or (courseware_llama_cuda_headers.results | selectattr('stat.exists', 'equalto', true) | list | length == 0)
|
||||
- courseware_llama_nvcc.rc != 0
|
||||
- courseware_llama_nvcc_fallback.rc != 0
|
||||
- (courseware_llama_cuda_headers.results | selectattr('stat.exists', 'equalto', true) | list | length == 0)
|
||||
|
||||
- name: Set CUDA compiler path for llama.cpp builds
|
||||
set_fact:
|
||||
courseware_llama_cuda_compiler: "{{ (courseware_llama_nvcc.stdout | trim) if courseware_llama_nvcc.rc == 0 else (courseware_llama_nvcc_fallback.stdout | trim) }}"
|
||||
courseware_llama_cuda_bin_dir: "{{ ((courseware_llama_nvcc.stdout | trim) if courseware_llama_nvcc.rc == 0 else (courseware_llama_nvcc_fallback.stdout | trim)) | dirname }}"
|
||||
when:
|
||||
- ansible_system == "Linux"
|
||||
- courseware_llama_nvcc.rc == 0 or courseware_llama_nvcc_fallback.rc == 0
|
||||
|
||||
- name: Set llama.cpp backend flag
|
||||
set_fact:
|
||||
courseware_llama_backend_flag: "{{ '-DGGML_METAL=ON' if ansible_system == 'Darwin' else '-DGGML_CUDA=ON' }}"
|
||||
|
||||
- name: Set llama.cpp build parallelism
|
||||
set_fact:
|
||||
courseware_llama_build_jobs: >-
|
||||
{{
|
||||
[
|
||||
1,
|
||||
[
|
||||
ansible_processor_vcpus | default(ansible_processor_nproc | default(1)) | int,
|
||||
((ansible_memtotal_mb | int) // 8192) | int,
|
||||
4
|
||||
] | min
|
||||
] | max
|
||||
}}
|
||||
|
||||
- name: Build llama.cpp CMake configure arguments
|
||||
set_fact:
|
||||
courseware_llama_cmake_configure_argv: >-
|
||||
{{
|
||||
[
|
||||
'cmake',
|
||||
'-S',
|
||||
courseware_repos_dir ~ '/llama.cpp',
|
||||
'-B',
|
||||
courseware_repos_dir ~ '/llama.cpp/build',
|
||||
'-DCMAKE_BUILD_TYPE=Release',
|
||||
courseware_llama_backend_flag
|
||||
]
|
||||
+
|
||||
(
|
||||
['-DCMAKE_CUDA_COMPILER=' ~ courseware_llama_cuda_compiler]
|
||||
if ansible_system == 'Linux' and (courseware_llama_cuda_compiler | default('') | length > 0)
|
||||
else []
|
||||
)
|
||||
}}
|
||||
|
||||
- name: Configure llama.cpp
|
||||
command:
|
||||
argv:
|
||||
- cmake
|
||||
- -S
|
||||
- "{{ courseware_repos_dir }}/llama.cpp"
|
||||
- -B
|
||||
- "{{ courseware_repos_dir }}/llama.cpp/build"
|
||||
- -DCMAKE_BUILD_TYPE=Release
|
||||
- "{{ courseware_llama_backend_flag }}"
|
||||
args:
|
||||
creates: "{{ courseware_repos_dir }}/llama.cpp/build/CMakeCache.txt"
|
||||
argv: "{{ courseware_llama_cmake_configure_argv }}"
|
||||
environment:
|
||||
PATH: "{{ (courseware_llama_cuda_bin_dir ~ ':' ~ ansible_env.PATH) if ansible_system == 'Linux' and (courseware_llama_cuda_bin_dir | default('') | length > 0) else ansible_env.PATH }}"
|
||||
CUDACXX: "{{ courseware_llama_cuda_compiler | default(omit) }}"
|
||||
|
||||
- name: Build llama.cpp tools
|
||||
command:
|
||||
@@ -73,12 +128,16 @@
|
||||
- cmake
|
||||
- --build
|
||||
- "{{ courseware_repos_dir }}/llama.cpp/build"
|
||||
- --parallel
|
||||
- "{{ courseware_llama_build_jobs }}"
|
||||
- --target
|
||||
- llama-cli
|
||||
- llama-quantize
|
||||
- llama-perplexity
|
||||
- llama-server
|
||||
- -j
|
||||
environment:
|
||||
PATH: "{{ (courseware_llama_cuda_bin_dir ~ ':' ~ ansible_env.PATH) if ansible_system == 'Linux' and (courseware_llama_cuda_bin_dir | default('') | length > 0) else ansible_env.PATH }}"
|
||||
CUDACXX: "{{ courseware_llama_cuda_compiler | default(omit) }}"
|
||||
|
||||
- name: Check system PATH slots for llama.cpp tools
|
||||
stat:
|
||||
|
||||
Reference in New Issue
Block a user