Upload Dockerfile with huggingface_hub
Browse files- Dockerfile +80 -92
Dockerfile
CHANGED
|
@@ -1,92 +1,80 @@
|
|
| 1 |
-
FROM nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04
|
| 2 |
-
|
| 3 |
-
# Build arg for GPU architectures
|
| 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 |
-
pip install --no-build-isolation .
|
| 82 |
-
|
| 83 |
-
RUN useradd -u 1000 -ms /bin/bash user
|
| 84 |
-
|
| 85 |
-
RUN chown -R user:user /workspace
|
| 86 |
-
|
| 87 |
-
RUN mkdir /home/user/.cache && \
|
| 88 |
-
chown -R user:user /home/user/.cache
|
| 89 |
-
|
| 90 |
-
COPY entrypoint.sh /workspace/entrypoint.sh
|
| 91 |
-
|
| 92 |
-
ENTRYPOINT ["/workspace/entrypoint.sh"]
|
|
|
|
| 1 |
+
FROM nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04
|
| 2 |
+
|
| 3 |
+
# Build arg for GPU architectures
|
| 4 |
+
ARG CUDA_ARCHITECTURES="8.0;8.6"
|
| 5 |
+
|
| 6 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 7 |
+
|
| 8 |
+
# Install system dependencies
|
| 9 |
+
RUN apt update && \
|
| 10 |
+
apt install -y \
|
| 11 |
+
python3 python3-pip git wget curl cmake ninja-build \
|
| 12 |
+
libgl1 libglib2.0-0 ffmpeg && \
|
| 13 |
+
apt clean
|
| 14 |
+
|
| 15 |
+
WORKDIR /workspace
|
| 16 |
+
|
| 17 |
+
COPY requirements.txt .
|
| 18 |
+
|
| 19 |
+
# Upgrade pip first
|
| 20 |
+
RUN pip install --upgrade pip setuptools wheel
|
| 21 |
+
|
| 22 |
+
# Install requirements if exists
|
| 23 |
+
RUN pip install -r requirements.txt
|
| 24 |
+
|
| 25 |
+
# Install PyTorch with CUDA support
|
| 26 |
+
RUN pip install --extra-index-url https://download.pytorch.org/whl/cu124 \
|
| 27 |
+
torch==2.6.0+cu124 torchvision==0.21.0+cu124
|
| 28 |
+
|
| 29 |
+
# Install SageAttention from git (patch GPU detection)
|
| 30 |
+
ENV TORCH_CUDA_ARCH_LIST="${CUDA_ARCHITECTURES}"
|
| 31 |
+
ENV FORCE_CUDA="1"
|
| 32 |
+
ENV MAX_JOBS="1"
|
| 33 |
+
|
| 34 |
+
COPY <<EOF /tmp/patch_setup.py
|
| 35 |
+
import os
|
| 36 |
+
with open('setup.py', 'r') as f:
|
| 37 |
+
content = f.read()
|
| 38 |
+
|
| 39 |
+
# Get architectures from environment variable
|
| 40 |
+
arch_list = os.environ.get('TORCH_CUDA_ARCH_LIST')
|
| 41 |
+
arch_set = '{' + ', '.join([f'"{arch}"' for arch in arch_list.split(';')]) + '}'
|
| 42 |
+
|
| 43 |
+
# Replace the GPU detection section
|
| 44 |
+
old_section = '''compute_capabilities = set()
|
| 45 |
+
device_count = torch.cuda.device_count()
|
| 46 |
+
for i in range(device_count):
|
| 47 |
+
major, minor = torch.cuda.get_device_capability(i)
|
| 48 |
+
if major < 8:
|
| 49 |
+
warnings.warn(f"skipping GPU {i} with compute capability {major}.{minor}")
|
| 50 |
+
continue
|
| 51 |
+
compute_capabilities.add(f"{major}.{minor}")'''
|
| 52 |
+
|
| 53 |
+
new_section = 'compute_capabilities = ' + arch_set + '''
|
| 54 |
+
print(f"Manually set compute capabilities: {compute_capabilities}")'''
|
| 55 |
+
|
| 56 |
+
content = content.replace(old_section, new_section)
|
| 57 |
+
|
| 58 |
+
with open('setup.py', 'w') as f:
|
| 59 |
+
f.write(content)
|
| 60 |
+
EOF
|
| 61 |
+
|
| 62 |
+
RUN git clone https://github.com/thu-ml/SageAttention.git /tmp/sageattention && \
|
| 63 |
+
cd /tmp/sageattention && \
|
| 64 |
+
python3 /tmp/patch_setup.py && \
|
| 65 |
+
pip install --no-build-isolation .
|
| 66 |
+
|
| 67 |
+
# --- FIX: Copy application code ---
|
| 68 |
+
COPY . /workspace
|
| 69 |
+
# ----------------------------------
|
| 70 |
+
|
| 71 |
+
RUN useradd -u 1000 -ms /bin/bash user
|
| 72 |
+
|
| 73 |
+
RUN chown -R user:user /workspace
|
| 74 |
+
|
| 75 |
+
RUN mkdir /home/user/.cache && \
|
| 76 |
+
chown -R user:user /home/user/.cache
|
| 77 |
+
|
| 78 |
+
COPY entrypoint.sh /workspace/entrypoint.sh
|
| 79 |
+
|
| 80 |
+
ENTRYPOINT ["/workspace/entrypoint.sh"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|