Skip to content

Commit 3f34700

Browse files
committed
docker(cuda_simple): upgrade to CUDA 12.8.1 and switch to source install
- Upgrade base image to nvidia/cuda:12.8.1-cudnn-devel-ubuntu22.04 - Optimize deps - Switch to git clone + pip install . for source building - Add documentation comments Signed-off-by: JamePeng <jame_peng@sina.com>
1 parent b6bf564 commit 3f34700

1 file changed

Lines changed: 29 additions & 11 deletions

File tree

docker/cuda_simple/Dockerfile

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,45 @@
1-
ARG CUDA_IMAGE="12.5.0-devel-ubuntu22.04"
1+
# Define the base image version with CUDA 12.8 and cuDNN for Ubuntu 22.04
2+
ARG CUDA_IMAGE="12.8.1-cudnn-devel-ubuntu22.04"
23
FROM nvidia/cuda:${CUDA_IMAGE}
34

45
# We need to set the host to 0.0.0.0 to allow outside access
56
ENV HOST 0.0.0.0
67

8+
# Install system dependencies:
79
RUN apt-get update && apt-get upgrade -y \
8-
&& apt-get install -y git build-essential \
9-
python3 python3-pip gcc wget \
10-
ocl-icd-opencl-dev opencl-headers clinfo \
11-
libclblast-dev libopenblas-dev \
12-
&& mkdir -p /etc/OpenCL/vendors && echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd
10+
&& apt-get install -y build-essential \
11+
ccache cmake curl gcc git wget \
12+
python3 python3-pip python3-wheel \
13+
libgomp1 libjpeg-dev libssl-dev libcurl4-openssl-dev
1314

15+
# Set the working directory for the container
16+
WORKDIR /app
17+
18+
# Copy the current directory contents into the container (useful for local config files or models)
1419
COPY . .
1520

16-
# setting build related env vars
17-
ENV CUDA_DOCKER_ARCH=all
21+
# Set the target GPU architecture (default allows CMake to auto-detect or use common archs)
22+
ENV CUDA_DOCKER_ARCH=default
1823
ENV GGML_CUDA=1
24+
ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:/usr/local/cuda/compat:/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH}"
25+
# Enable verbose build output
26+
ENV VERBOSE=1
27+
# Specific CUDA paths to ensure the compiler (nvcc) is found
28+
ENV CUDA_HOME="/usr/local/cuda/"
29+
ENV CUDA_PATH="/usr/local/cuda/:${PATH}"
30+
ENV CUDA_TOOLKIT_ROOT_DIR="/usr/local/cuda/"
31+
32+
# Install Python build tools and server dependencies
33+
RUN python3 -m pip install --upgrade pip pytest wheel packaging scikit-build setuptools fastapi uvicorn pydantic-settings sse-starlette starlette-context huggingface-hub
34+
35+
# Clone the source code. --recursive is CRITICAL to fetch the 'llama.cpp' submodule
36+
RUN git clone --recursive https://github.com/JamePeng/llama-cpp-python.git
1937

20-
# Install depencencies
21-
RUN python3 -m pip install --upgrade pip pytest cmake scikit-build setuptools fastapi uvicorn sse-starlette pydantic-settings starlette-context
38+
# Switch context to the cloned repository directory
39+
WORKDIR /app/llama-cpp-python
2240

2341
# Install llama-cpp-python (build with cuda)
24-
RUN CMAKE_ARGS="-DGGML_CUDA=on" pip install llama-cpp-python
42+
RUN CMAKE_ARGS="-DGGML_CUDA=on -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DCMAKE_CUDA_ARCHITECTURES=${CUDA_DOCKER_ARCH}" pip install .
2543

2644
# Run the server
2745
CMD python3 -m llama_cpp.server

0 commit comments

Comments
 (0)