fish-cpp: symlink libcuda.so stub into /usr/local/lib (CMAKE_LIBRARY_PATH alone didn't work)
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.
This commit is contained in:
@@ -27,14 +27,18 @@ RUN git clone --recurse-submodules https://github.com/rodrigomatta/s2.cpp.git \
|
|||||||
|
|
||||||
WORKDIR /src/s2.cpp
|
WORKDIR /src/s2.cpp
|
||||||
# CUDA Driver API symbols (cuMemSetAccess, cuDeviceGet, etc.) live in
|
# CUDA Driver API symbols (cuMemSetAccess, cuDeviceGet, etc.) live in
|
||||||
# libcuda.so which the NVIDIA driver provides at RUNTIME via --gpus
|
# libcuda.so which the NVIDIA driver provides at RUNTIME. Build-time
|
||||||
# mount. At build time there's no GPU, so we use the stubs library
|
# uses the stubs library at /usr/local/cuda/lib64/stubs/. CMake's
|
||||||
# at /usr/local/cuda/lib64/stubs/ which provides the symbols for
|
# find_library doesn't reliably pick it up via CMAKE_LIBRARY_PATH for
|
||||||
# linking but is NOT runnable. The runtime image uses the real
|
# nested ggml-cuda builds — the most robust fix is symlinking the stub
|
||||||
# driver-provided libcuda.so via NVIDIA's container runtime.
|
# into /usr/local/lib (which ld checks unconditionally) AND providing
|
||||||
ENV LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LIBRARY_PATH}
|
# 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 \
|
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
|
&& cmake --build build --parallel $(nproc) --target s2
|
||||||
|
|
||||||
# ── Stage 2: runtime — slim image with the binary + python shim ────────
|
# ── Stage 2: runtime — slim image with the binary + python shim ────────
|
||||||
|
|||||||
Reference in New Issue
Block a user