Ashish Ajin commited on
Commit
bdd38c0
Β·
1 Parent(s): 3645b11

Enable GPU support via CUDA base image

Browse files
Files changed (2) hide show
  1. Dockerfile +7 -2
  2. requirements.txt +2 -2
Dockerfile CHANGED
@@ -1,13 +1,16 @@
1
  # ───────────────────────────────────────────────────────────
2
  # Word-As-Image β€’ FastAPI GPU Space β€’ builds diffvg
3
  # ───────────────────────────────────────────────────────────
4
- FROM python:3.10-slim
5
 
6
  # β€”β€” OS packages needed by diffvg & image libs β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
7
  RUN apt-get update && apt-get install -y --no-install-recommends \
 
8
  build-essential git cmake ffmpeg pkg-config \
9
  libgl1-mesa-dev libglib2.0-0 libpng-dev libxrender1 xorg-dev \
10
- && rm -rf /var/lib/apt/lists/*
 
 
11
 
12
  # β€”β€” Non-root user per HF best practice β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
13
  RUN useradd -m -u 1000 appuser
@@ -25,6 +28,8 @@ ENV HF_HOME=/home/appuser/.cache/huggingface \
25
  # β€”β€” Python deps (NO diffvg here) β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
26
  COPY --chown=appuser requirements.txt .
27
  RUN pip install --upgrade pip \
 
 
28
  && pip install --no-cache-dir -r requirements.txt
29
 
30
  # β€”β€” Build diffvg from a known-good commit β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
 
1
  # ───────────────────────────────────────────────────────────
2
  # Word-As-Image β€’ FastAPI GPU Space β€’ builds diffvg
3
  # ───────────────────────────────────────────────────────────
4
+ FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04
5
 
6
  # β€”β€” OS packages needed by diffvg & image libs β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
7
  RUN apt-get update && apt-get install -y --no-install-recommends \
8
+ python3 python3-pip python3-venv \
9
  build-essential git cmake ffmpeg pkg-config \
10
  libgl1-mesa-dev libglib2.0-0 libpng-dev libxrender1 xorg-dev \
11
+ && rm -rf /var/lib/apt/lists/* \
12
+ && ln -s /usr/bin/python3 /usr/local/bin/python \
13
+ && ln -s /usr/bin/pip3 /usr/local/bin/pip
14
 
15
  # β€”β€” Non-root user per HF best practice β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
16
  RUN useradd -m -u 1000 appuser
 
28
  # β€”β€” Python deps (NO diffvg here) β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
29
  COPY --chown=appuser requirements.txt .
30
  RUN pip install --upgrade pip \
31
+ && pip install --no-cache-dir torch==2.3.1+cu118 torchvision==0.18.1+cu118 \
32
+ --extra-index-url https://download.pytorch.org/whl/cu118 \
33
  && pip install --no-cache-dir -r requirements.txt
34
 
35
  # β€”β€” Build diffvg from a known-good commit β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
requirements.txt CHANGED
@@ -1,6 +1,6 @@
1
- torch==2.3.1
2
- torchvision==0.18.1
3
  xformers==0.0.27
 
 
4
 
5
  accelerate==1.0.1
6
  annotated-types==0.7.0
 
 
 
1
  xformers==0.0.27
2
+ torch==2.3.1+cu118
3
+ torchvision==0.18.1+cu118
4
 
5
  accelerate==1.0.1
6
  annotated-types==0.7.0