tezuesh commited on
Commit
a745c5d
·
verified ·
1 Parent(s): 6b03d8c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -37
Dockerfile CHANGED
@@ -1,57 +1,58 @@
1
  FROM pytorch/pytorch:2.1.2-cuda12.1-cudnn8-runtime
2
 
3
- # NVIDIA Container Runtime Configuration
4
- ENV NVIDIA_VISIBLE_DEVICES=all \
5
- NVIDIA_DRIVER_CAPABILITIES=compute,utility \
6
  CUDA_HOME=/usr/local/cuda \
7
- PATH=${CUDA_HOME}/bin:${PATH} \
8
- LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} \
9
  TORCH_CUDA_ARCH_LIST="8.6" \
10
- FORCE_CUDA="1"
11
-
12
- WORKDIR /app
13
-
14
- # System Dependencies with Explicit Versions
15
- RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
16
- build-essential \
17
- python3-dev \
18
- git \
19
- ffmpeg \
20
- libsndfile1 \
21
- curl \
 
22
  && rm -rf /var/lib/apt/lists/*
23
 
24
- # Python Environment Setup
25
- RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel
 
 
26
 
27
- # Cache Directory Configuration
28
- RUN mkdir -p /app/cache && \
29
- chmod 777 /app/cache && \
30
- mkdir -p /app/src
31
 
32
- # Application Setup - Two-Stage Copy for Better Caching
33
  COPY requirements.txt /app/src/
34
  WORKDIR /app/src
35
- RUN pip install --no-cache-dir -r requirements.txt
36
 
37
- # Copy Application Code
38
  COPY . /app/src/
39
 
40
- # Environment Configuration
41
- ENV PYTHONUNBUFFERED=1 \
42
- MODEL_PATH=/app/cache \
43
  PYTHONPATH=/app/src:$PYTHONPATH \
44
  OMP_NUM_THREADS=1 \
45
  MKL_NUM_THREADS=1
46
 
47
- # GPU Verification with Detailed Output
48
- RUN python3 -c "import torch; \
49
- assert torch.cuda.is_available(), 'CUDA not available'; \
50
- device = torch.cuda.current_device(); \
51
- print(f'CUDA Device Index: {device}'); \
52
- print(f'CUDA Device Name: {torch.cuda.get_device_name(device)}'); \
53
- print(f'CUDA Device Arch: {torch.cuda.get_device_capability(device)}'); \
54
- print(f'CUDA Version: {torch.version.cuda}')"
55
 
56
  EXPOSE 8000
57
 
 
1
  FROM pytorch/pytorch:2.1.2-cuda12.1-cudnn8-runtime
2
 
3
+ # System-level configuration
4
+ ENV DEBIAN_FRONTEND=noninteractive \
5
+ PYTHONUNBUFFERED=1 \
6
  CUDA_HOME=/usr/local/cuda \
7
+ PATH=/usr/local/cuda/bin:$PATH \
8
+ LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH \
9
  TORCH_CUDA_ARCH_LIST="8.6" \
10
+ NVIDIA_VISIBLE_DEVICES=all \
11
+ NVIDIA_DRIVER_CAPABILITIES=compute,utility
12
+
13
+ # System dependencies with explicit version control
14
+ RUN apt-get update && apt-get install -y --no-install-recommends \
15
+ build-essential=12.9ubuntu3 \
16
+ python3-dev=3.10.6-1~22.04 \
17
+ python3-pip=22.0.2+dfsg-1ubuntu0.4 \
18
+ git=1:2.34.1-1ubuntu1.10 \
19
+ ffmpeg=7:4.4.2-0ubuntu0.22.04.1 \
20
+ libsndfile1=1.0.31-2ubuntu0.1 \
21
+ curl=7.81.0-1ubuntu1.15 \
22
+ && apt-get clean \
23
  && rm -rf /var/lib/apt/lists/*
24
 
25
+ # Python environment configuration
26
+ RUN ln -sf /usr/bin/python3 /usr/bin/python && \
27
+ curl -sS https://bootstrap.pypa.io/get-pip.py | python3 && \
28
+ python3 -m pip install --no-cache-dir pip==23.3.1 setuptools==69.0.3 wheel==0.42.0
29
 
30
+ # Application directory structure
31
+ WORKDIR /app
32
+ RUN mkdir -p /app/cache /app/src && \
33
+ chmod 777 /app/cache
34
 
35
+ # Dependencies installation (two-stage for better caching)
36
  COPY requirements.txt /app/src/
37
  WORKDIR /app/src
38
+ RUN python3 -m pip install --no-cache-dir -r requirements.txt
39
 
40
+ # Application code
41
  COPY . /app/src/
42
 
43
+ # Runtime environment
44
+ ENV MODEL_PATH=/app/cache \
 
45
  PYTHONPATH=/app/src:$PYTHONPATH \
46
  OMP_NUM_THREADS=1 \
47
  MKL_NUM_THREADS=1
48
 
49
+ # GPU verification with comprehensive diagnostics
50
+ RUN python3 -c 'import torch; \
51
+ assert torch.cuda.is_available(), "CUDA unavailable"; \
52
+ print(f"PyTorch: {torch.__version__}"); \
53
+ print(f"CUDA: {torch.version.cuda}"); \
54
+ print(f"GPU: {torch.cuda.get_device_name()}"); \
55
+ print(f"Arch: {torch.cuda.get_device_capability()}");'
 
56
 
57
  EXPOSE 8000
58