2023-07-07 20:25:25 +02:00
|
|
|
ARG UBUNTU_VERSION=22.04
|
|
|
|
# This needs to generally match the container host's environment.
|
2024-08-28 13:20:36 +02:00
|
|
|
ARG CUDA_VERSION=12.6.0
|
2023-07-07 20:25:25 +02:00
|
|
|
# Target the CUDA build image
|
|
|
|
ARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}
|
|
|
|
# Target the CUDA runtime image
|
|
|
|
ARG BASE_CUDA_RUN_CONTAINER=nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
|
|
|
|
|
2024-07-17 20:21:55 +02:00
|
|
|
FROM ${BASE_CUDA_DEV_CONTAINER} AS build
|
2023-07-07 20:25:25 +02:00
|
|
|
|
2024-08-28 13:20:36 +02:00
|
|
|
# CUDA architecture to build for (defaults to all supported archs)
|
|
|
|
ARG CUDA_DOCKER_ARCH=default
|
2023-07-07 20:25:25 +02:00
|
|
|
|
|
|
|
RUN apt-get update && \
|
2024-08-28 13:20:36 +02:00
|
|
|
apt-get install -y build-essential git cmake
|
2023-07-07 20:25:25 +02:00
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
COPY . .
|
|
|
|
|
2024-08-28 13:20:36 +02:00
|
|
|
# Use the default CUDA archs if not specified
|
|
|
|
RUN if [ "${CUDA_DOCKER_ARCH}" != "default" ]; then \
|
|
|
|
export CMAKE_ARGS="-DCMAKE_CUDA_ARCHITECTURES=${CUDA_DOCKER_ARCH}"; \
|
|
|
|
fi && \
|
2024-11-18 00:21:53 +01:00
|
|
|
cmake -B build -DGGML_NATIVE=OFF -DGGML_CUDA=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \
|
2024-11-14 18:04:35 +01:00
|
|
|
cmake --build build --config Release --target llama-cli -j$(nproc) && \
|
|
|
|
mkdir -p /app/lib && \
|
|
|
|
find build -name "*.so" -exec cp {} /app/lib \;
|
2023-07-07 20:25:25 +02:00
|
|
|
|
2024-07-17 20:21:55 +02:00
|
|
|
FROM ${BASE_CUDA_RUN_CONTAINER} AS runtime
|
2023-07-07 20:25:25 +02:00
|
|
|
|
2024-06-06 07:17:21 +02:00
|
|
|
RUN apt-get update && \
|
|
|
|
apt-get install -y libgomp1
|
|
|
|
|
2024-11-14 18:04:35 +01:00
|
|
|
COPY --from=build /app/lib/ /
|
|
|
|
COPY --from=build /app/build/bin/llama-cli /
|
2023-07-07 20:25:25 +02:00
|
|
|
|
2024-06-13 01:41:52 +02:00
|
|
|
ENTRYPOINT [ "/llama-cli" ]
|