|
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" |
2 | 3 | FROM nvidia/cuda:${CUDA_IMAGE} |
3 | 4 |
|
4 | 5 | # We need to set the host to 0.0.0.0 to allow outside access |
5 | 6 | ENV HOST 0.0.0.0 |
6 | 7 |
|
| 8 | +# Install system dependencies: |
7 | 9 | 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 |
13 | 14 |
|
| 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) |
14 | 19 | COPY . . |
15 | 20 |
|
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 |
18 | 23 | 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 |
19 | 37 |
|
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 |
22 | 40 |
|
23 | 41 | # 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 . |
25 | 43 |
|
26 | 44 | # Run the server |
27 | 45 | CMD python3 -m llama_cpp.server |
0 commit comments