torinriley commited on
Commit
b095bac
·
1 Parent(s): e5348a2

Switch to CUDA base image + cu121 torch to use GPU

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -13
Dockerfile CHANGED
@@ -1,28 +1,27 @@
1
- FROM python:3.11-slim
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive \
4
  OMP_NUM_THREADS=1
5
 
6
- # System libraries needed by OpenCV and ffmpeg
7
  RUN apt-get update && apt-get install -y \
 
8
  ffmpeg libsm6 libxext6 libgl1 \
9
- && rm -rf /var/lib/apt/lists/*
 
10
 
11
- # Install torch as a separate layer so Docker can cache it across rebuilds
12
- RUN pip install --no-cache-dir \
13
  torch torchvision \
14
- --index-url https://download.pytorch.org/whl/cpu
15
 
16
  WORKDIR /app
17
- # Copy files BEFORE pip install so basicsr_vendor is present
18
  COPY . .
19
 
20
- # Install basicsr from our vendored copy which has two patches applied:
21
- # 1. setup.py get_version() fix for Python 3.13+ (bonus: also works here)
22
- # 2. degradations.py import fix for torchvision >= 0.16
23
- RUN pip install --no-cache-dir ./basicsr_vendor
24
 
25
- RUN pip install --no-cache-dir \
26
  "realesrgan>=0.3.0" \
27
  "opencv-python-headless>=4.8.0" \
28
  "numpy>=1.24.0" \
@@ -36,4 +35,4 @@ USER user
36
  ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
37
 
38
  EXPOSE 7860
39
- CMD ["python", "app.py"]
 
1
+ FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive \
4
  OMP_NUM_THREADS=1
5
 
6
+ # Python 3.10 (Ubuntu 22.04 default) is fine — basicsr locals() bug is 3.13+ only
7
  RUN apt-get update && apt-get install -y \
8
+ python3 python3-pip python3-dev \
9
  ffmpeg libsm6 libxext6 libgl1 \
10
+ && rm -rf /var/lib/apt/lists/* \
11
+ && ln -sf /usr/bin/python3 /usr/bin/python
12
 
13
+ # Install torch with CUDA 12.1 support (compatible with CUDA 12.x hosts)
14
+ RUN pip3 install --no-cache-dir \
15
  torch torchvision \
16
+ --index-url https://download.pytorch.org/whl/cu121
17
 
18
  WORKDIR /app
 
19
  COPY . .
20
 
21
+ # Install basicsr from vendored patched source
22
+ RUN pip3 install --no-cache-dir ./basicsr_vendor
 
 
23
 
24
+ RUN pip3 install --no-cache-dir \
25
  "realesrgan>=0.3.0" \
26
  "opencv-python-headless>=4.8.0" \
27
  "numpy>=1.24.0" \
 
35
  ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
36
 
37
  EXPOSE 7860
38
+ CMD ["python3", "app.py"]