Spaces:
Sleeping
Sleeping
File size: 5,187 Bytes
876b664 6ce51a7 876b664 6ce51a7 876b664 6ce51a7 876b664 6ce51a7 876b664 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# Stage 1: Build Cuda toolkit
<<<<<<< HEAD
FROM ubuntu:22.04 as cuda-setup
ARG DEBIAN_FRONTEND=noninteractive
# Install necessary libraries including libxml2
RUN apt-get update && \
apt-get install -y gcc libxml2 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
COPY cuda_12.4.0_550.54.14_linux.run .
# Install wget, download cuda-toolkit and run
RUN chmod +x cuda_12.4.0_550.54.14_linux.run && \
./cuda_12.4.0_550.54.14_linux.run --silent --toolkit --override
# Second Stage: Copy necessary CUDA directories install flash-attn
FROM ubuntu:22.04 as base-layer
# Copy the CUDA toolkit from the first stage
COPY --from=cuda-setup /usr/local/cuda-12.4 /usr/local/cuda-12.4
# Set environment variables to enable CUDA commands
ENV PATH=/usr/local/cuda-12.4/bin:${PATH}
ENV LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:${LD_LIBRARY_PATH}
# Install Python, pip, and virtualenv
RUN apt-get update && \
apt-get install -y python3 python3-pip python3-venv git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create a virtual environment and install dependencies
RUN python3 -m venv /venv
ENV PATH="/venv/bin:$PATH"
FROM ubuntu:22.04 as cuda-setup
ARG DEBIAN_FRONTEND=noninteractive
# Install necessary libraries including libxml2
RUN apt-get update && \
apt-get install -y gcc libxml2 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
COPY cuda_12.4.0_550.54.14_linux.run .
# Install wget, download cuda-toolkit and run
RUN chmod +x cuda_12.4.0_550.54.14_linux.run && \
./cuda_12.4.0_550.54.14_linux.run --silent --toolkit --override
# Second Stage: Copy necessary CUDA directories install flash-attn
FROM ubuntu:22.04 as base-layer
# Copy the CUDA toolkit from the first stage
COPY --from=cuda-setup /usr/local/cuda-12.4 /usr/local/cuda-12.4
# Set environment variables to enable CUDA commands
ENV PATH=/usr/local/cuda-12.4/bin:${PATH}
ENV LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:${LD_LIBRARY_PATH}
# Install Python, pip, and virtualenv
RUN apt-get update && \
apt-get install -y python3 python3-pip python3-venv git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create a virtual environment and install dependencies
RUN python3 -m venv /venv
ENV PATH="/venv/bin:$PATH"
# 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
ENV LLAMA_CUBLAS=1
RUN pip install --no-cache-dir torch packaging wheel && \
pip install flash-attn && \
RUN pip install --no-cache-dir torch packaging wheel && \
pip install flash-attn && \
pip install gradio && \
CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama_cpp_python==0.2.55 && \
CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama_cpp_python==0.2.55 && \
=======
FROM drakosfire/cuda-base:latest as base-layer
# 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
ENV LLAMA_CUBLAS=1
RUN apt-get update && \
apt-get install -y python3 python3-pip python3-venv && \
pip install gradio && \
CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python && \
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
pip install pillow && \
pip install diffusers && \
pip install accelerate && \
pip install transformers && \
<<<<<<< HEAD
pip install peft && \
pip install pip install PyGithub
FROM ubuntu:22.04 as final-layer
COPY --from=base-layer /usr/local/cuda-12.4 /usr/local/cuda-12.4
COPY --from=base-layer /venv /venv
ENV PATH=/usr/local/cuda-12.4/bin:/venv/bin:${PATH}
ENV LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:${LD_LIBRARY_PATH}
ENV LLAMA_CPP_LIB=/venv/lib/python3.10/site-packages/llama_cpp/libllama.so
ENV VIRTUAL_ENV=/venv
# Install Python and create a user
RUN apt-get update && apt-get install -y python3 python3-venv && apt-get clean && rm -rf /var/lib/apt/lists/* && \
useradd -m -u 1000 user
# Install Python and create a user
RUN apt-get update && apt-get install -y python3 python3-venv && apt-get clean && rm -rf /var/lib/apt/lists/* && \
useradd -m -u 1000 user
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Set working directory and user
COPY . /home/user/app
# Set working directory and user
COPY . /home/user/app
WORKDIR /home/user/app
RUN chown -R user:user /home/user/app/ && \
mkdir -p /home/user/app/output && \
chown -R user:user /home/user/app/image_temp && \
chown -R user:user /home/user/app/output
=======
pip install peft
FROM base-layer as final-layer
RUN useradd -m -u 1000 user
# mkdir -p /home/user/.cache && \
# chmod 777 /home/user/.cache && \
# chown -R user:user /home/user/app/
# Set environment variables for copied builds of cuda and flash-attn in /venv
ENV PATH=/usr/local/cuda-12.4/bin:/venv/bin:${PATH}
ENV LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:${LD_LIBRARY_PATH}
ENV VIRTUAL_ENV=/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Set working directory and user
WORKDIR /home/user/app
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
USER user
# Set the entrypoint
EXPOSE 8000
ENTRYPOINT ["python", "main.py"] |