Spaces:
Build error
Build error
Update Dockerfile with Cuda support by default
Browse files- Dockerfile +28 -8
Dockerfile
CHANGED
@@ -1,31 +1,52 @@
|
|
1 |
-
|
2 |
-
|
|
|
3 |
|
4 |
# Set up a new user named "user" with user ID 1000
|
5 |
RUN useradd -m -u 1000 user
|
|
|
6 |
# Install the dependencies
|
7 |
-
RUN apt-get update && apt-get -y
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# Switch to the user 'user'
|
10 |
USER user
|
11 |
|
|
|
|
|
|
|
|
|
12 |
# Set home to the user's home directory and Poetry's environment variables
|
13 |
ENV HOME=/home/user \
|
14 |
PATH=/home/user/.local/bin:$PATH \
|
|
|
15 |
POETRY_NO_INTERACTION=1 \
|
16 |
POETRY_VIRTUALENVS_IN_PROJECT=1 \
|
17 |
POETRY_VIRTUALENVS_CREATE=1 \
|
18 |
POETRY_CACHE_DIR=/tmp/poetry_cache \
|
19 |
-
|
|
|
|
|
20 |
|
21 |
# Set the working directory to /app
|
22 |
WORKDIR $HOME/app
|
23 |
|
24 |
# Update pip and wheel
|
25 |
-
RUN pip install --upgrade pip setuptools wheel
|
26 |
|
27 |
# Install poetry
|
28 |
-
RUN pip install poetry
|
29 |
|
30 |
# Copy the poetry files
|
31 |
COPY --chown=user ./backend/pyproject.toml ./backend/poetry.lock $HOME/app/
|
@@ -34,8 +55,7 @@ COPY --chown=user ./backend/pyproject.toml ./backend/poetry.lock $HOME/app/
|
|
34 |
COPY --chown=user ./backend $HOME/app
|
35 |
|
36 |
# Install the dependencies
|
37 |
-
RUN poetry
|
38 |
-
RUN poetry install --without dev && \
|
39 |
rm -rf /tmp/poetry_cache
|
40 |
|
41 |
# Change to the package directory
|
|
|
1 |
+
ARG CUDA_IMAGE="12.1.1-devel-ubuntu22.04"
|
2 |
+
# Build with Cuda 12.1.1 and Ubuntu 22.04
|
3 |
+
FROM nvidia/cuda:${CUDA_IMAGE}
|
4 |
|
5 |
# Set up a new user named "user" with user ID 1000
|
6 |
RUN useradd -m -u 1000 user
|
7 |
+
|
8 |
# Install the dependencies
|
9 |
+
RUN apt-get update && apt-get upgrade -y \
|
10 |
+
&& apt-get install -y git build-essential \
|
11 |
+
python3.11 gcc wget \
|
12 |
+
ocl-icd-opencl-dev opencl-headers clinfo \
|
13 |
+
cmake protobuf-compiler pkg-config \
|
14 |
+
libclblast-dev libopenblas-dev \
|
15 |
+
liblapack-dev liblapacke-dev libeigen3-dev libboost-all-dev \
|
16 |
+
&& mkdir -p /etc/OpenCL/vendors && echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd
|
17 |
+
|
18 |
+
# Install pip for python 3.11
|
19 |
+
RUN wget https://bootstrap.pypa.io/get-pip.py && \
|
20 |
+
python3.11 get-pip.py && \
|
21 |
+
rm get-pip.py
|
22 |
|
23 |
# Switch to the user 'user'
|
24 |
USER user
|
25 |
|
26 |
+
# Setting build related env vars
|
27 |
+
ENV CUDA_DOCKER_ARCH=all
|
28 |
+
ENV LLAMA_CUBLAS=1
|
29 |
+
|
30 |
# Set home to the user's home directory and Poetry's environment variables
|
31 |
ENV HOME=/home/user \
|
32 |
PATH=/home/user/.local/bin:$PATH \
|
33 |
+
PYTHONUNBUFFERED=1 \
|
34 |
POETRY_NO_INTERACTION=1 \
|
35 |
POETRY_VIRTUALENVS_IN_PROJECT=1 \
|
36 |
POETRY_VIRTUALENVS_CREATE=1 \
|
37 |
POETRY_CACHE_DIR=/tmp/poetry_cache \
|
38 |
+
# Build llama-cpp-python with default cuda support
|
39 |
+
CMAKE_ARGS="-DLLAMA_CUBLAS=on"
|
40 |
+
# CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS"
|
41 |
|
42 |
# Set the working directory to /app
|
43 |
WORKDIR $HOME/app
|
44 |
|
45 |
# Update pip and wheel
|
46 |
+
RUN python3.11 -m pip install --upgrade pip setuptools wheel
|
47 |
|
48 |
# Install poetry
|
49 |
+
RUN python3.11 -m pip install poetry
|
50 |
|
51 |
# Copy the poetry files
|
52 |
COPY --chown=user ./backend/pyproject.toml ./backend/poetry.lock $HOME/app/
|
|
|
55 |
COPY --chown=user ./backend $HOME/app
|
56 |
|
57 |
# Install the dependencies
|
58 |
+
RUN poetry install --without dev,torch-cpu && \
|
|
|
59 |
rm -rf /tmp/poetry_cache
|
60 |
|
61 |
# Change to the package directory
|