File size: 1,963 Bytes
e2644bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
be1fb1c
 
 
e2644bf
be1fb1c
e2644bf
bc588c7
 
 
e2644bf
 
bc588c7
e2644bf
 
 
 
be1fb1c
e2644bf
 
 
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
FROM nvidia/cuda:12.4.1-devel-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive
ENV PIP_NO_CACHE_DIR=1
ENV PATH=/opt/venv/bin:$PATH

# System dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    python3.10 \
    python3.10-venv \
    python3-pip \
    python3-dev \
    git \
    wget \
    curl \
    build-essential \
    libstdc++-11-dev \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# Virtual environment
RUN python3.10 -m venv /opt/venv
RUN pip install --upgrade pip setuptools wheel

# PyTorch 2.5.1 (CUDA 12.4)
RUN pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 \
    --index-url https://download.pytorch.org/whl/cu124

# Flash Attention 2.8.3 (pre-compiled wheel for torch 2.5 + CUDA 12.4)
RUN pip install packaging ninja psutil
RUN pip install xformers==0.0.28.post3 --index-url https://download.pytorch.org/whl/cu124
RUN pip install https://github.com/Dao-AILab/flash-attention/releases/download/v2.8.3/flash_attn-2.8.3+cu12torch2.5cxx11abiFALSE-cp310-cp310-linux_x86_64.whl

# Unsloth
RUN pip install unsloth
RUN pip install --upgrade accelerate

# Re-pin torch (unsloth may upgrade it)
RUN pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 \
    --index-url https://download.pytorch.org/whl/cu124
RUN pip install xformers==0.0.28.post3 --index-url https://download.pytorch.org/whl/cu124

# Remove torchao (incompatible with torch 2.5.1, needs torch.int1 from 2.6+)
RUN pip uninstall -y torchao || true

# Phoenix dependencies
RUN pip install timm zuko

# Gradio + utilities
RUN pip install gradio numpy Pillow huggingface_hub matplotlib

# HF cache to persistent storage (mount bucket at /data in Space settings)
ENV HF_HOME=/data/hf_cache

# Create user for HF Spaces
RUN useradd -m -u 1000 user
RUN mkdir -p /data/hf_cache && chown -R user:user /data
USER user
WORKDIR /home/user/app

# Copy application
COPY --chown=user:user . /home/user/app

EXPOSE 7860
CMD ["python", "app.py"]