File size: 1,872 Bytes
3f4c08e
 
4091af9
28a9da3
 
 
6b03d8c
a745c5d
353f03e
 
 
a745c5d
b2dc3fc
a745c5d
28a9da3
c85b388
b2dc3fc
 
 
 
353f03e
28a9da3
f1490e9
43ce8b7
1de92f4
43ce8b7
 
 
9c0a4f6
 
1de92f4
 
 
 
43ce8b7
 
 
 
 
b2dc3fc
353f03e
b2dc3fc
506ec9e
43ce8b7
22d5f88
43ce8b7
6b03d8c
353f03e
 
b2dc3fc
353f03e
28a9da3
f1490e9
43ce8b7
 
 
 
f1490e9
353f03e
 
0f46c51
 
 
28a9da3
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
FROM nvidia/cuda:12.3.2-cudnn9-devel-ubuntu22.04


# Set environment variables
ENV PYTHONUNBUFFERED=1 \
    DEBIAN_FRONTEND=noninteractive \
    CUDA_HOME=/usr/local/cuda \
    PATH=/usr/local/cuda/bin:$PATH \
    LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH \
    NVIDIA_VISIBLE_DEVICES=all \
    NVIDIA_DRIVER_CAPABILITIES=compute,utility

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    python3 \
    python3-pip \
    python3-dev \
    build-essential \
    ffmpeg \
    libsndfile1 \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user
# In your Dockerfile:
RUN useradd -m -s /bin/bash appuser && \
    mkdir -p /home/appuser/.cache/torch && \
    mkdir -p /home/appuser/.triton && \
    chown -R appuser:appuser /home/appuser && \
    chmod 755 /home/appuser/.triton

# Add these ENV variables 
ENV TRITON_CACHE_DIR=/home/appuser/.triton \
    TORCH_INDUCTOR_CACHE_DIR=/home/appuser/.triton

# Set cache directories environment variables
ENV TORCH_HOME=/home/appuser/.cache/torch \
    TRITON_CACHE_DIR=/home/appuser/.triton

# Upgrade pip and install build tools
RUN python3 -m pip install --upgrade pip setuptools wheel

WORKDIR /app
RUN chown appuser:appuser /app

COPY --chown=appuser:appuser requirements.txt .

# Install PyTorch with CUDA support
RUN pip3 install --no-cache-dir torch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cu121

# Install other requirements
RUN pip3 install --no-cache-dir -r requirements.txt

COPY --chown=appuser:appuser . .

# Switch to non-root user
USER appuser

# Simple CUDA test
RUN python3 -c "import torch; print('CUDA available:', torch.cuda.is_available()); print('CUDA version:', torch.version.cuda); print('Device count:', torch.cuda.device_count())"

EXPOSE 8000

CMD ["python3", "server.py"]