File size: 1,481 Bytes
5b2f23d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM pytorch/pytorch:2.7.1-cuda12.6-cudnn9-devel
ENV CUDA_HOME=/usr/local/cuda
ENV PATH="${CUDA_HOME}/bin:${PATH}"
ENV LD_LIBRARY_PATH="${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}"
ENV TORCH_CUDA_ARCH_LIST="7.5"
ENV USE_CUDA=1

# Verify CUDA setup
RUN nvcc --version && which nvcc
RUN apt-get update && apt-get install -y \
    git fish tmux curl ffmpeg \
    libgl1-mesa-glx libglib2.0-0 \
    build-essential ninja-build python3.10-venv \
    && rm -rf /var/lib/apt/lists/*
    
# Create non-root user
RUN useradd -m -u 1000 user

# Create HF cache with correct ownership
ENV HF_HOME=/home/user/.cache/huggingface
RUN mkdir -p $HF_HOME && chown -R user:user /home/user


ENV OMP_NUM_THREADS=1
ENV MKL_NUM_THREADS=1
ENV NUMEXPR_NUM_THREADS=1

# Switch to user before creating venv
USER user
WORKDIR /home/user/app

# Create virtualenv
RUN python3 -m venv /home/user/venv
ENV PATH="/home/user/venv/bin:$PATH"

# Dependencies
COPY --chown=user:user requirements.txt .
RUN pip install --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# Editable installs
RUN pip install --no-cache-dir -e ./src/video-sam2 && \
    pip install --no-cache-dir --use-pep517 -e ./src/GroundingDINO && \
    pip install --no-cache-dir -e ./src/LASER && \
    pip install --no-cache-dir -e ./vine_hf

RUN cd src/GroundingDINO && \
    python3 setup.py build_ext --force --inplace

# Copy app
COPY --chown=user:user . .

EXPOSE 7860
ENV GRADIO_SERVER_NAME="0.0.0.0"
CMD ["python3", "app.py"]