Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +75 -65
Dockerfile
CHANGED
|
@@ -1,126 +1,136 @@
|
|
| 1 |
# =============================================================================
|
| 2 |
-
# ADUC-SDR Video Suite —
|
|
|
|
| 3 |
# CUDA 12.8 | PyTorch 2.8.0+cu128 | Ubuntu 22.04
|
| 4 |
# =============================================================================
|
| 5 |
FROM nvidia/cuda:12.8.0-devel-ubuntu22.04
|
| 6 |
|
| 7 |
-
LABEL maintainer="Carlos Rodrigues dos Santos
|
| 8 |
-
LABEL description="High-performance Diffusers stack with
|
| 9 |
-
LABEL version="
|
| 10 |
LABEL cuda_version="12.8.0"
|
| 11 |
LABEL python_version="3.10"
|
| 12 |
LABEL pytorch_version="2.8.0+cu128"
|
| 13 |
LABEL gpu_optimized_for="8x_NVIDIA_L40S"
|
| 14 |
|
| 15 |
-
#
|
|
|
|
|
|
|
| 16 |
ENV DEBIAN_FRONTEND=noninteractive TZ=UTC LANG=C.UTF-8 LC_ALL=C.UTF-8 \
|
| 17 |
PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 \
|
| 18 |
-
PIP_NO_CACHE_DIR=
|
| 19 |
|
| 20 |
-
# GPU
|
| 21 |
-
ENV NVIDIA_VISIBLE_DEVICES=all
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
|
| 26 |
-
# Threads
|
| 27 |
ENV OMP_NUM_THREADS=8 MKL_NUM_THREADS=8 MAX_JOBS=160
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
ENV PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512,garbage_collection_threshold:0.8
|
| 31 |
-
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
ENV APP_HOME=/app
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
ENV HF_HOME=/data/.cache/huggingface
|
| 39 |
-
ENV TORCH_HOME=/data/.cache/torch
|
| 40 |
-
ENV HF_DATASETS_CACHE=/data/.cache/datasets
|
| 41 |
-
ENV TRANSFORMERS_CACHE=/data/.cache/transformers
|
| 42 |
-
ENV DIFFUSERS_CACHE=/data/.cache/diffusers
|
| 43 |
-
ENV HF_HUB_ENABLE_HF_TRANSFER=1
|
| 44 |
-
ENV TOKENIZERS_PARALLELISM=false
|
| 45 |
|
| 46 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
RUN useradd -m -u 1000 -s /bin/bash appuser && \
|
| 48 |
-
mkdir -p /data /
|
| 49 |
-
/data/.cache/huggingface /data/.cache/torch \
|
| 50 |
-
/data/.cache/datasets /data/.cache/transformers /data/.cache/diffusers && \
|
| 51 |
-
chown -R appuser:appuser /data
|
| 52 |
-
|
| 53 |
-
# Models live in /data/models and are visible at /app/models
|
| 54 |
-
ENV MODELS_DIR=/data/models
|
| 55 |
-
RUN ln -sf /data/models /app/models
|
| 56 |
|
| 57 |
-
#
|
| 58 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 59 |
build-essential gosu tree cmake git git-lfs curl wget ffmpeg ninja-build \
|
| 60 |
python3.10 python3.10-dev python3.10-distutils python3-pip \
|
| 61 |
ca-certificates libglib2.0-0 libgl1 \
|
| 62 |
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 63 |
|
| 64 |
-
RUN ln -sf /usr/bin/python3.10 /usr/bin/
|
| 65 |
-
ln -sf /usr/bin/python3.10 /usr/bin/python && \
|
| 66 |
python3 -m pip install --upgrade pip
|
| 67 |
|
| 68 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
RUN pip install --index-url https://download.pytorch.org/whl/cu128 \
|
| 70 |
torch>=2.8.0+cu128 torchvision>=0.23.0+cu128 torchaudio>=2.8.0+cu128
|
| 71 |
|
| 72 |
-
#
|
| 73 |
RUN pip install packaging ninja cmake pybind11 scikit-build cython hf_transfer "numpy>=1.24.4"
|
| 74 |
|
| 75 |
-
# Triton 3.x
|
| 76 |
RUN pip uninstall -y triton || true && \
|
| 77 |
pip install -v --no-build-isolation triton==3.4.0
|
| 78 |
|
| 79 |
-
|
| 80 |
-
# FlashAttention 2.8.x
|
| 81 |
RUN pip install flash-attn==2.8.3 --no-build-isolation || \
|
| 82 |
pip install flash-attn==2.8.2 --no-build-isolation || \
|
| 83 |
pip install flash-attn==2.8.1 --no-build-isolation || \
|
| 84 |
pip install flash-attn==2.8.0.post2 --no-build-isolation
|
| 85 |
|
| 86 |
-
#
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
| 88 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 89 |
|
| 90 |
-
#
|
| 91 |
RUN pip install --upgrade bitsandbytes
|
| 92 |
|
| 93 |
-
#
|
| 94 |
RUN echo "Installing custom wheels..." && \
|
| 95 |
pip install --no-cache-dir \
|
| 96 |
"https://huggingface.co/euIaxs22/Aduc-sdr/resolve/main/apex-0.1-cp310-cp310-linux_x86_64.whl" \
|
| 97 |
"https://huggingface.co/euIaxs22/Aduc-sdr/resolve/main/dropout_layer_norm-0.1-cp310-cp310-linux_x86_64.whl"
|
| 98 |
|
| 99 |
-
#
|
| 100 |
-
# Optional: q8_kernels + LTX-Video (enable if needed; ensure wheel ABI)
|
| 101 |
RUN pip install --no-cache-dir \
|
| 102 |
"https://huggingface.co/euIaxs22/Aduc-sdr/resolve/main/q8_kernels-0.0.5-cp310-cp310-linux_x86_64.whl"
|
| 103 |
-
# RUN git clone https://github.com/Lightricks/LTX-Video.git /data/LTX-Video && \
|
| 104 |
-
# cd /data/LTX-Video && python -m pip install -e .[inference]
|
| 105 |
-
# ====================================================================
|
| 106 |
|
| 107 |
-
#
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
COPY entrypoint.sh ./app/entrypoint.sh
|
| 112 |
|
| 113 |
-
#
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
-
#
|
| 117 |
-
|
| 118 |
-
|
|
|
|
| 119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
VOLUME /data
|
| 121 |
|
| 122 |
-
|
| 123 |
USER appuser
|
| 124 |
|
| 125 |
-
#
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# =============================================================================
|
| 2 |
+
# ADUC-SDR Video Suite — Dockerfile Otimizado
|
| 3 |
+
# Preserva a estrutura de instalação original para alta performance.
|
| 4 |
# CUDA 12.8 | PyTorch 2.8.0+cu128 | Ubuntu 22.04
|
| 5 |
# =============================================================================
|
| 6 |
FROM nvidia/cuda:12.8.0-devel-ubuntu22.04
|
| 7 |
|
| 8 |
+
LABEL maintainer="Carlos Rodrigues dos Santos"
|
| 9 |
+
LABEL description="ADUC-SDR: High-performance Diffusers stack for 8x NVIDIA L40S with LTX-Video and SeedVR"
|
| 10 |
+
LABEL version="5.0.0"
|
| 11 |
LABEL cuda_version="12.8.0"
|
| 12 |
LABEL python_version="3.10"
|
| 13 |
LABEL pytorch_version="2.8.0+cu128"
|
| 14 |
LABEL gpu_optimized_for="8x_NVIDIA_L40S"
|
| 15 |
|
| 16 |
+
# =============================================================================
|
| 17 |
+
# 1. Variáveis de Ambiente e Configuração de Paths
|
| 18 |
+
# =============================================================================
|
| 19 |
ENV DEBIAN_FRONTEND=noninteractive TZ=UTC LANG=C.UTF-8 LC_ALL=C.UTF-8 \
|
| 20 |
PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 \
|
| 21 |
+
PIP_NO_CACHE_DIR=0 PIP_DISABLE_PIP_VERSION_CHECK=1
|
| 22 |
|
| 23 |
+
# --- Configurações de GPU e Computação ---
|
| 24 |
+
ENV NVIDIA_VISIBLE_DEVICES=all \
|
| 25 |
+
TORCH_CUDA_ARCH_LIST="8.9" \
|
| 26 |
+
CUDA_DEVICE_ORDER=PCI_BUS_ID \
|
| 27 |
+
CUDA_DEVICE_MAX_CONNECTIONS=32
|
| 28 |
|
| 29 |
+
# --- Configurações de Threads ---
|
| 30 |
ENV OMP_NUM_THREADS=8 MKL_NUM_THREADS=8 MAX_JOBS=160
|
| 31 |
|
| 32 |
+
# --- Configurações de Alocador de Memória e Caches de GPU ---
|
| 33 |
+
ENV PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512,garbage_collection_threshold:0.8 \
|
| 34 |
+
CUDA_LAUNCH_BLOCKING=0 CUDA_CACHE_MAXSIZE=2147483648 CUDA_CACHE_DISABLE=0
|
| 35 |
|
| 36 |
+
# --- Paths da Aplicação e Dados Persistentes ---
|
| 37 |
+
ENV APP_HOME=/app \
|
| 38 |
+
HF_HOME=/data/.cache/huggingface \
|
| 39 |
+
TORCH_HOME=/data/.cache/torch \
|
| 40 |
+
HF_DATASETS_CACHE=/data/.cache/datasets \
|
| 41 |
+
TRANSFORMERS_CACHE=/data/.cache/transformers \
|
| 42 |
+
DIFFUSERS_CACHE=/data/.cache/diffusers \
|
| 43 |
+
HF_HUB_ENABLE_HF_TRANSFER=1 \
|
| 44 |
+
TOKENIZERS_PARALLELISM=false
|
| 45 |
|
| 46 |
+
WORKDIR $APP_HOME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
# =============================================================================
|
| 49 |
+
# 2. Setup de Usuário e Sistema
|
| 50 |
+
# =============================================================================
|
| 51 |
+
# Cria usuário não-root e diretórios de dados/app.
|
| 52 |
+
# As permissões finais serão aplicadas no final.
|
| 53 |
RUN useradd -m -u 1000 -s /bin/bash appuser && \
|
| 54 |
+
mkdir -p /data $APP_HOME /app/output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
+
# --- Instalação de Pacotes de Sistema e Python ---
|
| 57 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 58 |
build-essential gosu tree cmake git git-lfs curl wget ffmpeg ninja-build \
|
| 59 |
python3.10 python3.10-dev python3.10-distutils python3-pip \
|
| 60 |
ca-certificates libglib2.0-0 libgl1 \
|
| 61 |
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 62 |
|
| 63 |
+
RUN ln -sf /usr/bin/python3.10 /usr/bin/python && \
|
|
|
|
| 64 |
python3 -m pip install --upgrade pip
|
| 65 |
|
| 66 |
+
# =============================================================================
|
| 67 |
+
# 3. Instalação da Toolchain de Machine Learning (Mantida 100% Original)
|
| 68 |
+
# =============================================================================
|
| 69 |
+
|
| 70 |
+
# --- PyTorch para CUDA 12.8 ---
|
| 71 |
RUN pip install --index-url https://download.pytorch.org/whl/cu128 \
|
| 72 |
torch>=2.8.0+cu128 torchvision>=0.23.0+cu128 torchaudio>=2.8.0+cu128
|
| 73 |
|
| 74 |
+
# --- Ferramentas de Compilação, Triton e FlashAttention ---
|
| 75 |
RUN pip install packaging ninja cmake pybind11 scikit-build cython hf_transfer "numpy>=1.24.4"
|
| 76 |
|
| 77 |
+
# --- Triton 3.x ---
|
| 78 |
RUN pip uninstall -y triton || true && \
|
| 79 |
pip install -v --no-build-isolation triton==3.4.0
|
| 80 |
|
| 81 |
+
# --- FlashAttention 2.8.x ---
|
|
|
|
| 82 |
RUN pip install flash-attn==2.8.3 --no-build-isolation || \
|
| 83 |
pip install flash-attn==2.8.2 --no-build-isolation || \
|
| 84 |
pip install flash-attn==2.8.1 --no-build-isolation || \
|
| 85 |
pip install flash-attn==2.8.0.post2 --no-build-isolation
|
| 86 |
|
| 87 |
+
# =============================================================================
|
| 88 |
+
# 4. Instalação das Dependências da Aplicação
|
| 89 |
+
# =============================================================================
|
| 90 |
+
# Copia e instala requirements.txt primeiro para otimizar o cache de camadas do Docker.
|
| 91 |
+
COPY --chown=appuser:appuser requirements.txt ./requirements.txt
|
| 92 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 93 |
|
| 94 |
+
# --- Instalação de bitsandbytes e Wheels Customizados (Mantido 100% Original) ---
|
| 95 |
RUN pip install --upgrade bitsandbytes
|
| 96 |
|
| 97 |
+
# Instala wheels customizados (Apex, etc.)
|
| 98 |
RUN echo "Installing custom wheels..." && \
|
| 99 |
pip install --no-cache-dir \
|
| 100 |
"https://huggingface.co/euIaxs22/Aduc-sdr/resolve/main/apex-0.1-cp310-cp310-linux_x86_64.whl" \
|
| 101 |
"https://huggingface.co/euIaxs22/Aduc-sdr/resolve/main/dropout_layer_norm-0.1-cp310-cp310-linux_x86_64.whl"
|
| 102 |
|
| 103 |
+
# Instala q8_kernels
|
|
|
|
| 104 |
RUN pip install --no-cache-dir \
|
| 105 |
"https://huggingface.co/euIaxs22/Aduc-sdr/resolve/main/q8_kernels-0.0.5-cp310-cp310-linux_x86_64.whl"
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
+
# NOTA: A clonagem do LTX-Video foi removida daqui.
|
| 108 |
+
# Esta tarefa agora é gerenciada pelo entrypoint para garantir a persistência dos dados.
|
| 109 |
+
# # RUN git clone https://github.com/Lightricks/LTX-Video.git /data/LTX-Video && \
|
| 110 |
+
# # cd /data/LTX-Video && python -m pip install -e .[inference]
|
|
|
|
| 111 |
|
| 112 |
+
# =============================================================================
|
| 113 |
+
# 5. Cópia do Código-Fonte e Configuração Final
|
| 114 |
+
# =============================================================================
|
| 115 |
+
# Copia o restante do código-fonte da aplicação por último.
|
| 116 |
+
COPY --chown=appuser:appuser . .
|
| 117 |
|
| 118 |
+
# Garante que todos os scripts de inicialização sejam executáveis
|
| 119 |
+
# e que o usuário 'appuser' seja o dono de todos os arquivos.
|
| 120 |
+
RUN chown -R appuser:appuser $APP_HOME /data && \
|
| 121 |
+
chmod +x /app/entrypoint.sh /app/start.sh /app/info.sh /app/builder.sh
|
| 122 |
|
| 123 |
+
# =============================================================================
|
| 124 |
+
# 6. Ponto de Entrada
|
| 125 |
+
# =============================================================================
|
| 126 |
+
# Expõe o diretório /data para ser montado como um volume persistente.
|
| 127 |
VOLUME /data
|
| 128 |
|
| 129 |
+
# Define o usuário padrão para a execução do contêiner.
|
| 130 |
USER appuser
|
| 131 |
|
| 132 |
+
# Define o script que será executado na inicialização do contêiner.
|
| 133 |
+
ENTRYPOINT ["/app/entrypoint.sh"]
|
| 134 |
+
|
| 135 |
+
# Define o comando padrão a ser executado pelo entrypoint.
|
| 136 |
+
CMD ["/app/start.sh"]
|