fix: dockerfile
This commit is contained in:
@@ -54,6 +54,4 @@ examples/
|
|||||||
assets/
|
assets/
|
||||||
docs/
|
docs/
|
||||||
tests/
|
tests/
|
||||||
README.md
|
|
||||||
README.docker.md
|
README.docker.md
|
||||||
LICENSE
|
|
||||||
|
|||||||
35
Dockerfile
35
Dockerfile
@@ -1,5 +1,5 @@
|
|||||||
# Use NVIDIA CUDA base image with Python 3.10 (CUDA 12.8 for RTX 5080)
|
# Use NVIDIA CUDA base image with Python 3.12 (CUDA 12.8 for RTX 5080)
|
||||||
FROM nvidia/cuda:12.8.0-cudnn-runtime-ubuntu22.04
|
FROM nvidia/cuda:12.8.0-base-ubuntu24.04
|
||||||
|
|
||||||
# Set environment variables
|
# Set environment variables
|
||||||
ENV DEBIAN_FRONTEND=noninteractive \
|
ENV DEBIAN_FRONTEND=noninteractive \
|
||||||
@@ -8,27 +8,33 @@ ENV DEBIAN_FRONTEND=noninteractive \
|
|||||||
PIP_NO_CACHE_DIR=1 \
|
PIP_NO_CACHE_DIR=1 \
|
||||||
CUDA_VISIBLE_DEVICES=0
|
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 \
|
RUN apt-get update && apt-get install -y \
|
||||||
python3.10 \
|
python3 \
|
||||||
python3.10-dev \
|
|
||||||
python3-pip \
|
python3-pip \
|
||||||
|
python3-venv \
|
||||||
git \
|
git \
|
||||||
libglib2.0-0 \
|
libglib2.0-0 \
|
||||||
libsm6 \
|
libsm6 \
|
||||||
libxext6 \
|
libxext6 \
|
||||||
libxrender-dev \
|
libxrender-dev \
|
||||||
libgomp1 \
|
libgomp1 \
|
||||||
libgl1-mesa-glx \
|
|
||||||
wget \
|
wget \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Set Python 3.10 as default
|
# Create symlink for python command
|
||||||
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 && \
|
RUN ln -sf /usr/bin/python3 /usr/bin/python
|
||||||
update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
|
|
||||||
|
|
||||||
# Upgrade pip
|
# Configure pip to use Tsinghua mirror (清华源) and allow system-wide installs
|
||||||
RUN python3 -m pip install --upgrade pip setuptools wheel
|
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
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -37,9 +43,12 @@ WORKDIR /app
|
|||||||
COPY . /app/
|
COPY . /app/
|
||||||
|
|
||||||
# Install PyTorch with CUDA support first (cu124 is compatible with CUDA 12.8)
|
# 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
|
# 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 .
|
RUN pip install -e .
|
||||||
|
|
||||||
# Install additional dependencies for server
|
# 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
|
CMD python3 -c "import requests; requests.get('http://localhost:8001/', timeout=5)" || exit 1
|
||||||
|
|
||||||
# Default command to start the server (port 8001)
|
# Default command to start the server (port 8001)
|
||||||
CMD ["texteller", "launch", "server", "-p", "8001"]
|
CMD ["texteller", "launch", "-p", "8001"]
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ check_docker() {
|
|||||||
# Check if NVIDIA Container Toolkit is installed
|
# Check if NVIDIA Container Toolkit is installed
|
||||||
check_nvidia_docker() {
|
check_nvidia_docker() {
|
||||||
print_info "Checking NVIDIA Container Toolkit..."
|
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_error "NVIDIA Container Toolkit not working properly."
|
||||||
print_info "Please install it with:"
|
print_info "Please install it with:"
|
||||||
echo " sudo apt-get install -y nvidia-container-toolkit"
|
echo " sudo apt-get install -y nvidia-container-toolkit"
|
||||||
@@ -113,8 +113,12 @@ start_container() {
|
|||||||
--name $CONTAINER_NAME \
|
--name $CONTAINER_NAME \
|
||||||
--gpus '"device=0"' \
|
--gpus '"device=0"' \
|
||||||
-p $PORT:8001 \
|
-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 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_NUM_REPLICAS=1 \
|
||||||
-e RAY_NCPU_PER_REPLICA=4 \
|
-e RAY_NCPU_PER_REPLICA=4 \
|
||||||
-e RAY_NGPU_PER_REPLICA=1 \
|
-e RAY_NGPU_PER_REPLICA=1 \
|
||||||
|
|||||||
Reference in New Issue
Block a user