From dd571a3529cf6c691ca90808df21f0a2b23810de Mon Sep 17 00:00:00 2001 From: Vuong Hoang Date: Tue, 28 Apr 2026 01:20:01 -0700 Subject: [PATCH] fish-cpp: symlink libcuda.so stub into /usr/local/lib (CMAKE_LIBRARY_PATH alone didn't work) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Second attempt's CMAKE_LIBRARY_PATH + LIBRARY_PATH didn't get picked up by ggml's nested CMake — same linker errors as the first run. Robust fix: symlink the stub at /usr/local/cuda/lib64/stubs/libcuda.so into /usr/local/lib (which ld searches unconditionally) and provide both libcuda.so AND libcuda.so.1 (the SONAME ggml-cuda's libggml-cuda.so links against). ldconfig refreshes the cache. The symlinks live only in the build stage. The runtime image inherits the real driver-provided libcuda.so.1 via NVIDIA's container runtime mount, so the stubs never get used at execution time. --- stacks/fish-cpp/Dockerfile | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/stacks/fish-cpp/Dockerfile b/stacks/fish-cpp/Dockerfile index f8d1007..f95723c 100644 --- a/stacks/fish-cpp/Dockerfile +++ b/stacks/fish-cpp/Dockerfile @@ -27,14 +27,18 @@ RUN git clone --recurse-submodules https://github.com/rodrigomatta/s2.cpp.git \ WORKDIR /src/s2.cpp # CUDA Driver API symbols (cuMemSetAccess, cuDeviceGet, etc.) live in -# libcuda.so which the NVIDIA driver provides at RUNTIME via --gpus -# mount. At build time there's no GPU, so we use the stubs library -# at /usr/local/cuda/lib64/stubs/ which provides the symbols for -# linking but is NOT runnable. The runtime image uses the real -# driver-provided libcuda.so via NVIDIA's container runtime. -ENV LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LIBRARY_PATH} +# libcuda.so which the NVIDIA driver provides at RUNTIME. Build-time +# uses the stubs library at /usr/local/cuda/lib64/stubs/. CMake's +# find_library doesn't reliably pick it up via CMAKE_LIBRARY_PATH for +# nested ggml-cuda builds — the most robust fix is symlinking the stub +# into /usr/local/lib (which ld checks unconditionally) AND providing +# libcuda.so.1 (the SONAME ggml-cuda links against). The symlinks live +# only in this build stage; the runtime image gets the real driver- +# provided libcuda.so.1 via NVIDIA's container runtime. +RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/lib/libcuda.so \ + && ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/lib/libcuda.so.1 \ + && ldconfig RUN cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release -DS2_CUDA=ON \ - -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs \ && cmake --build build --parallel $(nproc) --target s2 # ── Stage 2: runtime — slim image with the binary + python shim ────────