fix: dockerfile
Some checks failed
Sphinx: Render docs / build (push) Has been cancelled
Python Linting / lint (push) Has been cancelled
Run Tests with Pytest / test (push) Has been cancelled

This commit is contained in:
2025-12-15 23:21:47 +08:00
parent ba0968b2da
commit 6813f3d4f7
3 changed files with 28 additions and 17 deletions

View File

@@ -54,6 +54,4 @@ examples/
assets/
docs/
tests/
README.md
README.docker.md
LICENSE

View File

@@ -1,5 +1,5 @@
# Use NVIDIA CUDA base image with Python 3.10 (CUDA 12.8 for RTX 5080)
FROM nvidia/cuda:12.8.0-cudnn-runtime-ubuntu22.04
# Use NVIDIA CUDA base image with Python 3.12 (CUDA 12.8 for RTX 5080)
FROM nvidia/cuda:12.8.0-base-ubuntu24.04
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive \
@@ -8,27 +8,33 @@ ENV DEBIAN_FRONTEND=noninteractive \
PIP_NO_CACHE_DIR=1 \
CUDA_VISIBLE_DEVICES=0
# Install Python 3.10 and system dependencies
# Configure apt to use Tsinghua mirror (清华源)
RUN sed -i 's@//archive.ubuntu.com@//mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/ubuntu.sources && \
sed -i 's@//security.ubuntu.com@//mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/ubuntu.sources
# Install Python and system dependencies (Ubuntu 24.04 uses Python 3.12)
RUN apt-get update && apt-get install -y \
python3.10 \
python3.10-dev \
python3 \
python3-pip \
python3-venv \
git \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
libgl1-mesa-glx \
wget \
&& rm -rf /var/lib/apt/lists/*
# Set Python 3.10 as default
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 && \
update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
# Create symlink for python command
RUN ln -sf /usr/bin/python3 /usr/bin/python
# Upgrade pip
RUN python3 -m pip install --upgrade pip setuptools wheel
# Configure pip to use Tsinghua mirror (清华源) and allow system-wide installs
RUN python3 -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
python3 -m pip config set global.break-system-packages true
# Upgrade pip (ignore system-installed packages)
RUN pip install --upgrade --ignore-installed pip setuptools wheel
# Set working directory
WORKDIR /app
@@ -37,9 +43,12 @@ WORKDIR /app
COPY . /app/
# Install PyTorch with CUDA support first (cu124 is compatible with CUDA 12.8)
RUN pip install torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cu124
# Note: PyTorch uses official mirror as Tsinghua doesn't host CUDA builds
RUN pip install torch torchvision
# Install the package and dependencies
# Set version manually since .git is excluded by .dockerignore
ENV SETUPTOOLS_SCM_PRETEND_VERSION=1.0.0
RUN pip install -e .
# Install additional dependencies for server
@@ -56,5 +65,5 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python3 -c "import requests; requests.get('http://localhost:8001/', timeout=5)" || exit 1
# Default command to start the server (port 8001)
CMD ["texteller", "launch", "server", "-p", "8001"]
CMD ["texteller", "launch", "-p", "8001"]

View File

@@ -59,7 +59,7 @@ check_docker() {
# Check if NVIDIA Container Toolkit is installed
check_nvidia_docker() {
print_info "Checking NVIDIA Container Toolkit..."
if ! docker run --rm --gpus all nvidia/cuda:12.1.0-base-ubuntu22.04 nvidia-smi &> /dev/null; then
if ! docker run --rm --gpus all nvidia/cuda:12.8.0-base-ubuntu24.04 nvidia-smi &> /dev/null; then
print_error "NVIDIA Container Toolkit not working properly."
print_info "Please install it with:"
echo " sudo apt-get install -y nvidia-container-toolkit"
@@ -113,8 +113,12 @@ start_container() {
--name $CONTAINER_NAME \
--gpus '"device=0"' \
-p $PORT:8001 \
-v "$MODEL_PATH:/root/.cache/huggingface/hub/models--OleehyO--TexTeller:ro" \
--shm-size=2g \
-v "$HOME/.cache/huggingface:/root/.cache/huggingface:ro" \
-e CUDA_VISIBLE_DEVICES=0 \
-e HF_HOME=/root/.cache/huggingface \
-e HF_HUB_OFFLINE=1 \
-e TRANSFORMERS_OFFLINE=1 \
-e RAY_NUM_REPLICAS=1 \
-e RAY_NCPU_PER_REPLICA=4 \
-e RAY_NGPU_PER_REPLICA=1 \