TheDrakosfire commited on
Commit
013a60a
1 Parent(s): a3d5ef4

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +49 -13
Dockerfile CHANGED
@@ -1,12 +1,47 @@
1
  # Stage 1: Build Cuda toolkit
2
- FROM drakosfire/cuda-base:latest as base-layer
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  # Llama.cpp requires the ENV variable be set to signal the CUDA build and be built with the CMAKE variables from pip for python use
5
  ENV LLAMA_CUBLAS=1
6
- RUN apt-get update && \
7
- apt-get install -y python3 python3-pip python3-venv && \
8
  pip install gradio && \
9
- CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python && \
10
  pip install pillow && \
11
  pip install diffusers && \
12
  pip install accelerate && \
@@ -14,24 +49,25 @@ RUN apt-get update && \
14
  pip install peft && \
15
  pip install pip install PyGithub
16
 
17
- FROM base-layer as final-layer
18
 
19
- RUN useradd -m -u 1000 user
20
-
21
- # Set environment variables for copied builds of cuda and flash-attn in /venv
22
 
23
  ENV PATH=/usr/local/cuda-12.4/bin:/venv/bin:${PATH}
24
  ENV LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:${LD_LIBRARY_PATH}
25
 
26
  ENV VIRTUAL_ENV=/venv
27
- RUN python3 -m venv $VIRTUAL_ENV
28
- ENV PATH="$VIRTUAL_ENV/bin:$PATH"
29
 
30
- # Copy local files to working directory and activate user
31
- COPY . /home/user/app/
 
 
 
 
 
32
  WORKDIR /home/user/app
33
 
34
-
35
  USER user
36
 
37
  # Set the entrypoint
 
1
  # Stage 1: Build Cuda toolkit
2
+ FROM ubuntu:22.04 as cuda-setup
3
+
4
+
5
+ ARG DEBIAN_FRONTEND=noninteractive
6
+
7
+ # Install necessary libraries including libxml2
8
+ RUN apt-get update && \
9
+ apt-get install -y gcc libxml2 && \
10
+ apt-get clean && \
11
+ rm -rf /var/lib/apt/lists/*
12
+
13
+ COPY cuda_12.4.0_550.54.14_linux.run .
14
+
15
+ # Install wget, download cuda-toolkit and run
16
+ RUN chmod +x cuda_12.4.0_550.54.14_linux.run && \
17
+ ./cuda_12.4.0_550.54.14_linux.run --silent --toolkit --override
18
+
19
+ # Second Stage: Copy necessary CUDA directories install flash-attn
20
+ FROM ubuntu:22.04 as base-layer
21
+
22
+ # Copy the CUDA toolkit from the first stage
23
+ COPY --from=cuda-setup /usr/local/cuda-12.4 /usr/local/cuda-12.4
24
+
25
+ # Set environment variables to enable CUDA commands
26
+ ENV PATH=/usr/local/cuda-12.4/bin:${PATH}
27
+ ENV LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:${LD_LIBRARY_PATH}
28
+
29
+ # Install Python, pip, and virtualenv
30
+ RUN apt-get update && \
31
+ apt-get install -y python3 python3-pip python3-venv git && \
32
+ apt-get clean && \
33
+ rm -rf /var/lib/apt/lists/*
34
+
35
+ # Create a virtual environment and install dependencies
36
+ RUN python3 -m venv /venv
37
+ ENV PATH="/venv/bin:$PATH"
38
 
39
  # Llama.cpp requires the ENV variable be set to signal the CUDA build and be built with the CMAKE variables from pip for python use
40
  ENV LLAMA_CUBLAS=1
41
+ RUN pip install --no-cache-dir torch packaging wheel && \
42
+ pip install flash-attn && \
43
  pip install gradio && \
44
+ CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama_cpp_python==0.2.55 && \
45
  pip install pillow && \
46
  pip install diffusers && \
47
  pip install accelerate && \
 
49
  pip install peft && \
50
  pip install pip install PyGithub
51
 
 
52
 
53
+ FROM ubuntu:22.04 as final-layer
54
+ COPY --from=base-layer /usr/local/cuda-12.4 /usr/local/cuda-12.4
55
+ COPY --from=base-layer /venv /venv
56
 
57
  ENV PATH=/usr/local/cuda-12.4/bin:/venv/bin:${PATH}
58
  ENV LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:${LD_LIBRARY_PATH}
59
 
60
  ENV VIRTUAL_ENV=/venv
 
 
61
 
62
+ # Install Python and create a user
63
+ RUN apt-get update && apt-get install -y python3 python3-venv && apt-get clean && rm -rf /var/lib/apt/lists/* && \
64
+ useradd -m -u 1000 user
65
+
66
+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
67
+ # Set working directory and user
68
+ COPY . /home/user/app
69
  WORKDIR /home/user/app
70
 
 
71
  USER user
72
 
73
  # Set the entrypoint