ayushpfullstack commited on
Commit
fb75d64
·
verified ·
1 Parent(s): c494a9e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -13
Dockerfile CHANGED
@@ -1,30 +1,28 @@
1
- # STEP 1: Change this line to a CUDA 11.7.1 base image
2
- FROM nvidia/cuda:11.7.1-devel-ubuntu22.04
3
 
4
  # Set up the environment
5
  ENV DEBIAN_FRONTEND=noninteractive
6
  ENV PYTHONUNBUFFERED=1
7
 
8
- # Install Python and pip
9
- RUN apt-get update && apt-get install -y \
10
- python3.10 python3-pip \
11
- && rm -rf /var/lib/apt/lists/*
12
 
13
- # Set the working directory inside the container
14
  WORKDIR /app
15
 
16
- # Set a writable cache directory for Hugging Face models
17
  ENV HF_HOME=/app/cache
18
 
19
- # Create the cache directory and give it open permissions
20
  RUN mkdir -p /app/cache && chmod 777 /app/cache
21
 
22
- # STEP 2: Change this line to install PyTorch for CUDA 11.7
23
- RUN pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
24
 
25
  # Copy and install the rest of the Python dependencies
26
  COPY requirements.txt .
27
- RUN pip3 install --no-cache-dir -r requirements.txt
28
 
29
  # Copy your main application code
30
  COPY main.py .
@@ -32,5 +30,5 @@ COPY main.py .
32
  # Expose the port your API will run on
33
  EXPOSE 8000
34
 
35
- # The command to start the Uvicorn server when the container runs
36
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
 
1
+ # Start from a standard Python 3.10 image
2
+ FROM python:3.10-slim-buster
3
 
4
  # Set up the environment
5
  ENV DEBIAN_FRONTEND=noninteractive
6
  ENV PYTHONUNBUFFERED=1
7
 
8
+ # Install system dependencies needed for OpenCV
9
+ RUN apt-get update && apt-get install -y libgl1-mesa-glx && rm -rf /var/lib/apt/lists/*
 
 
10
 
11
+ # Set the working directory
12
  WORKDIR /app
13
 
14
+ # Set a writable cache directory
15
  ENV HF_HOME=/app/cache
16
 
17
+ # Create the cache directory
18
  RUN mkdir -p /app/cache && chmod 777 /app/cache
19
 
20
+ # Install PyTorch for CUDA 11.3. It will link to the host's CUDA libraries at runtime.
21
+ RUN pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113
22
 
23
  # Copy and install the rest of the Python dependencies
24
  COPY requirements.txt .
25
+ RUN pip install --no-cache-dir -r requirements.txt
26
 
27
  # Copy your main application code
28
  COPY main.py .
 
30
  # Expose the port your API will run on
31
  EXPOSE 8000
32
 
33
+ # The command to start the Uvicorn server
34
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]