tezuesh commited on
Commit
0f46c51
·
verified ·
1 Parent(s): a2cecaa

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -10
Dockerfile CHANGED
@@ -20,22 +20,37 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
20
  && apt-get clean \
21
  && rm -rf /var/lib/apt/lists/*
22
 
23
- # Python environment configuration
24
  RUN ln -sf /usr/bin/python3 /usr/bin/python && \
25
  curl -sS https://bootstrap.pypa.io/get-pip.py | python3 && \
26
  python3 -m pip install --no-cache-dir pip==23.3.1 setuptools==69.0.3 wheel==0.42.0
27
 
 
28
  WORKDIR /app
 
 
29
 
30
- # Copy requirements first to leverage Docker cache
31
- COPY requirements.txt .
 
 
32
 
33
- # Install PyTorch first (separately to avoid conflicts)
34
- RUN pip3 install --no-cache-dir torch==2.1.2 torchvision==0.16.2 --index-url https://download.pytorch.org/whl/cu121
35
 
36
- # Then install other requirements
37
- RUN pip3 install --no-cache-dir -r requirements.txt
 
 
 
38
 
39
- # Create directories after all installations
40
- RUN mkdir -p /app/cache /app/src && \
41
- chmod 777 /app/cache
 
 
 
 
 
 
 
 
 
20
  && apt-get clean \
21
  && rm -rf /var/lib/apt/lists/*
22
 
 
23
  RUN ln -sf /usr/bin/python3 /usr/bin/python && \
24
  curl -sS https://bootstrap.pypa.io/get-pip.py | python3 && \
25
  python3 -m pip install --no-cache-dir pip==23.3.1 setuptools==69.0.3 wheel==0.42.0
26
 
27
+ # Application directory structure
28
  WORKDIR /app
29
+ RUN mkdir -p /app/cache /app/src && \
30
+ chmod 777 /app/cache
31
 
32
+ # Dependencies installation (two-stage for better caching)
33
+ COPY requirements.txt /app/src/
34
+ WORKDIR /app/src
35
+ RUN python3 -m pip install --no-cache-dir -r requirements.txt
36
 
37
+ # Application code
38
+ COPY . /app/src/
39
 
40
+ # Runtime environment
41
+ ENV MODEL_PATH=/app/cache \
42
+ PYTHONPATH=/app/src:$PYTHONPATH \
43
+ OMP_NUM_THREADS=1 \
44
+ MKL_NUM_THREADS=1
45
 
46
+ # # GPU verification with comprehensive diagnostics
47
+ RUN python3 -c 'import torch; \
48
+ assert torch.cuda.is_available(), "CUDA unavailable"; \
49
+ print(f"PyTorch: {torch.__version__}"); \
50
+ print(f"CUDA: {torch.version.cuda}"); \
51
+ print(f"GPU: {torch.cuda.get_device_name()}"); \
52
+ print(f"Arch: {torch.cuda.get_device_capability()}");'
53
+
54
+ EXPOSE 8000
55
+
56
+ CMD ["python", "server.py"]