Skip to content

Commit fdfa9b6

Browse files
mhotanclaude
andcommitted
fix(llamacpp): make the default CUDA image build (slim toolkit + nvcc on PATH)
build_llama_cpp_image's default CUDA image failed to build on constrained image builders, for two independent reasons found driving a real GPU serve end to end: 1. Full `cuda-toolkit-12-8` metapackage. It drags in cuda-nsight-systems (a GUI profiler: Java/GTK/X11, ~2 GB) that a headless build never uses, bloating the image and OOM-killing resource-constrained builders mid-install. Replace it with the compile-only subset (cuda-nvcc + cudart/driver stubs + cuBLAS/cuRAND dev, ~2.8 GB). 2. `No CMAKE_CUDA_COMPILER could be found`. The image's PATH env (which includes $CUDA_HOME/bin, where nvcc lives) is applied *after* the cmake configure/build RUN steps, so nvcc is not on PATH during the build. Set PATH inline on the cmake configure and build commands. With both fixes the default `build_llama_cpp_image()` compiles llama-server and the app serves an OpenAI-compatible /v1 endpoint on a GPU node (verified on a live control plane). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Michael Hotan <mike@union.ai>
1 parent 1b5b01c commit fdfa9b6

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

plugins/llamacpp/src/flyteplugins/llamacpp/_constants.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
LLAMA_SERVER_BINARY = f"{LLAMA_CPP_INSTALL_DIR}/build/bin/llama-server"
66

77
CUDA_HOME = "/usr/local/cuda-12.8"
8-
CUDA_TOOLKIT_PACKAGE = "cuda-toolkit-12-8"
8+
# Compile-only CUDA subset for a headless llama.cpp (GGML_CUDA=ON) build: nvcc + the
9+
# cudart/driver stubs + cuBLAS/cuRAND dev headers. The full `cuda-toolkit-12-8`
10+
# metapackage also pulls in a GUI profiler and its desktop toolchain (~2 GB) that a
11+
# headless build never uses, needlessly bloating the image and its build.
12+
CUDA_TOOLKIT_PACKAGE = "cuda-nvcc-12-8 cuda-cudart-dev-12-8 cuda-driver-dev-12-8 libcublas-dev-12-8 libcurand-dev-12-8"
913
# CUDA stubs let the linker resolve libcuda.so on GPU-less build machines; the real
1014
# driver library is injected by the container runtime on the serving node.
1115
CUDA_STUB_LIB = f"{CUDA_HOME}/lib64/stubs"

plugins/llamacpp/src/flyteplugins/llamacpp/_image.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ def build_llama_cpp_image(
9595
]
9696
)
9797
cmake_configure = (
98+
# nvcc lives at $CUDA_HOME/bin; the image's PATH env is applied after these
99+
# build RUNs, so set it inline or cmake reports "No CMAKE_CUDA_COMPILER".
100+
f"PATH={CUDA_HOME}/bin:$PATH "
98101
f"LIBRARY_PATH={CUDA_STUB_LIB}:$LIBRARY_PATH "
99102
f"cmake -S {LLAMA_CPP_INSTALL_DIR} -B {LLAMA_CPP_INSTALL_DIR}/build "
100103
"-DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON "
@@ -127,7 +130,7 @@ def build_llama_cpp_image(
127130
# fatal EBADENGINE; override it so install proceeds (Node here satisfies
128131
# the UI's real Vite requirement).
129132
_run_script(
130-
f"PATH={NODE_HOME}/bin:$PATH npm_config_engine_strict=false "
133+
f"PATH={NODE_HOME}/bin:{CUDA_HOME}/bin:$PATH npm_config_engine_strict=false "
131134
f"{cmake_build_prefix}"
132135
f"cmake --build {LLAMA_CPP_INSTALL_DIR}/build --config Release "
133136
"-j $(nproc) --target llama-server"

0 commit comments

Comments
 (0)