marcosremar2 commited on
Commit
422f10d
·
1 Parent(s): dbf9b27

Update PDF to Markdown converter API with NVIDIA L4 support

Browse files
Files changed (2) hide show
  1. Dockerfile +11 -27
  2. requirements.txt +5 -5
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
 
@@ -31,33 +31,17 @@ WORKDIR /app
31
  # Copy requirements first
32
  COPY requirements.txt .
33
 
34
- # Install PyTorch dependencies with specific versions known to work with transformers
35
- # Using torch 2.0.1 with compatible torchvision 0.15.2 which is a proven stable combination
36
- RUN pip install --no-cache-dir --upgrade pip && \
37
- pip install --no-cache-dir torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2+cu118 --extra-index-url https://download.pytorch.org/whl/cu118
 
38
 
39
- # Ensure transformers is pinned to a compatible version
40
- RUN pip install --no-cache-dir transformers==4.30.2
41
 
42
- # Install remaining Python dependencies
43
- RUN grep -v "torch\|torchvision\|torchaudio\|transformers" requirements.txt > requirements_no_torch.txt && \
44
- pip install --no-cache-dir -r requirements_no_torch.txt
45
-
46
- # Create output directories
47
- RUN mkdir -p /app/output/images && \
48
- chmod -R 777 /app/output
49
-
50
- # Copy application code
51
- COPY app/ /app/app/
52
- COPY pdf_converter/ /app/pdf_converter/
53
- COPY app.py .
54
-
55
- # Set environment variables for GPU
56
- ENV NVIDIA_VISIBLE_DEVICES=all
57
- ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
58
-
59
- # Expose port 7860 for Hugging Face Spaces
60
  EXPOSE 7860
61
 
62
- # Command to run the application on port 7860
63
- CMD ["python3", "app.py"]
 
1
+ FROM nvidia/cuda:12.1.1-devel-ubuntu22.04
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
 
 
31
  # Copy requirements first
32
  COPY requirements.txt .
33
 
34
+ # Install PyTorch dependencies with explicit compatible versions for NVIDIA L4
35
+ RUN pip3 install --no-cache-dir --upgrade pip && \
36
+ 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 && \
37
+ pip3 install --no-cache-dir transformers==4.36.2 && \
38
+ pip3 install --no-cache-dir -r requirements.txt
39
 
40
+ # Copy the rest of the application
41
+ COPY . .
42
 
43
+ # Expose port
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  EXPOSE 7860
45
 
46
+ # Command to run the application
47
+ CMD ["python3", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
requirements.txt CHANGED
@@ -2,8 +2,8 @@ fastapi==0.104.1
2
  uvicorn==0.23.2
3
  python-multipart==0.0.6
4
  marker-pdf==1.6.2
5
- # Torch packages are installed directly in Dockerfile
6
- # torch==2.0.1
7
- # torchvision==0.15.2
8
- # torchaudio==2.0.2
9
- # transformers==4.30.2
 
2
  uvicorn==0.23.2
3
  python-multipart==0.0.6
4
  marker-pdf==1.6.2
5
+ # PyTorch packages installed directly in Dockerfile
6
+ # torch==2.1.2
7
+ # torchvision==0.16.2
8
+ # torchaudio==2.1.2
9
+ # transformers==4.36.2