File size: 2,468 Bytes
d3d4cc6 0b85eee f6a30e4 7f659d7 d3d4cc6 0b85eee 198c15d d3d4cc6 72610cd 0b85eee 7f659d7 51bd735 0b85eee 7f659d7 f6a30e4 d3d4cc6 f6a30e4 d3d4cc6 f6a30e4 3afecba f6a30e4 149e0d8 f6a30e4 149e0d8 f6a30e4 149e0d8 7f659d7 e8b5f16 f6a30e4 |
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 |
FROM ghcr.io/huggingface/text-generation-inference:3.3.4@sha256:91822fefc613d742f19f56b321925e81e41690dda29673c070fc68a65ae6bdb2
# Install system dependencies
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential git cmake ninja-build pkg-config curl ca-certificates gnupg software-properties-common \
python3-pip python3.11 python3.11-dev python3.11-venv python3.11-distutils python3-dev tzdata && \
ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime && dpkg-reconfigure --frontend noninteractive tzdata && \
curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub | \
gpg --dearmor --batch --yes -o /usr/share/keyrings/cuda-archive-keyring.gpg && \
echo "deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64 /" \
> /etc/apt/sources.list.d/cuda.list && \
apt-get update && \
apt-get install -y --no-install-recommends cuda-compiler-11-8 && \
rm -rf /var/lib/apt/lists/* && \
ldconfig
# Use Python 3.11 by default
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2
# Upgrade pip and install PyTorch
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
# Build and install diffvg (with thrust support)
RUN git clone --depth 1 --recursive https://github.com/BachiLi/diffvg.git /tmp/diffvg && \
cd /tmp/diffvg && \
# Replace internal pybind11, keep thrust submodule
rm -rf pybind11 && \
git clone --depth 1 --branch v2.12.1 https://github.com/pybind/pybind11.git pybind11 && \
sed -i 's/^\s*cmake_minimum_required(VERSION .*$/cmake_minimum_required(VERSION 3.5)/' pybind11/CMakeLists.txt && \
mkdir build && cd build && \
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=14 \
-DDIFFVG_CUDA=0 \
-DTHRUST_INCLUDE_DIR=/tmp/diffvg/thrust && \
make -j$(nproc) && \
cd /tmp/diffvg && python3 setup.py install && \
rm -rf /tmp/diffvg
# Copy the application code and install Python dependencies
COPY . /app
WORKDIR /app
RUN python3 -m pip install --no-cache-dir -r requirements.txt
# Launch the FastAPI server on container start
ENTRYPOINT ["uvicorn", "rest_api:app", "--host", "0.0.0.0", "--port", "7860"]
|