File size: 1,699 Bytes
7545345
 
3a8bfcd
 
 
 
 
f9969cb
7545345
3a8bfcd
 
 
 
 
 
7545345
3a8bfcd
25f0270
a9e38f5
25f0270
3a8bfcd
7545345
 
25f0270
239fdc4
3a8bfcd
 
 
036eb61
f9969cb
 
25f0270
 
 
987f5b5
3a8bfcd
c2f05a4
 
467e0ea
 
987f5b5
3a8bfcd
f9969cb
3a8bfcd
25f0270
f9969cb
 
 
 
6a77bfb
f9969cb
6a77bfb
 
3a8bfcd
 
f9969cb
 
25f0270
 
f9969cb
 
 
3a8bfcd
 
f9969cb
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
# Use Python 3.10 as the base image
FROM python:3.10-slim

# Install system dependencies
RUN apt-get update && apt-get install -y \
    ffmpeg \
    git \
    build-essential \
    ninja-build \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user
RUN useradd -m -u 1000 user
WORKDIR /app

# Install Python dependencies in correct order
RUN pip install --no-cache-dir --upgrade pip && \
    # Install numpy<2 first for compatibility
    pip install --no-cache-dir 'numpy<2' && \
    # Install PyTorch and other core dependencies
    pip install --no-cache-dir \
        torch==2.1.0 \
        torchvision==0.16.0 \
        ninja \
        transformers \
        accelerate \
        qwen-vl-utils[decord]==0.0.8 \
        fastapi \
        uvicorn[standard] \
        python-multipart \
        pillow \
        pydantic \
        supervision && \
    # Install AutoAWQ last
    pip install --no-cache-dir autoawq[cpu]


RUN pip install git+https://github.com/huggingface/transformers accelerate


RUN pip install intel-extension-for-pytorch
# Copy application files
COPY --chown=user:user . /app

# Create required directories and set permissions
RUN mkdir -p /home/user/.cache/huggingface && \
    mkdir -p /temp && \
    chown -R user:user /home/user/.cache && \
    chown -R user:user /temp

# Switch to non-root user
USER user

# Set environment variables
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    TRANSFORMERS_CACHE=/home/user/.cache/huggingface \
    TORCH_HOME=/home/user/.cache/torch \
    HF_HOME=/home/user/.cache/huggingface

# Expose the port
EXPOSE 7860

# Command to run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]