banao-tech commited on
Commit
be70c20
·
verified ·
1 Parent(s): beccd45

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -15
Dockerfile CHANGED
@@ -1,35 +1,46 @@
1
- # Use Python 3.9 slim base image
2
- FROM python:3.9-slim
3
-
4
- # Install system dependencies
5
- RUN apt-get update && apt-get install -y \
6
- libgl1-mesa-glx \
 
 
 
7
  libglib2.0-0 \
8
  wget \
9
  git \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
- # Set working directory
 
 
 
 
 
 
 
 
 
13
  WORKDIR /app
14
 
15
- # Copy requirements and install dependencies
16
  COPY requirements.txt .
17
  RUN pip install --no-cache-dir -r requirements.txt
18
 
19
- # Create directories for models and temporary files with proper permissions
20
- RUN mkdir -p /app/weights/icon_detect /app/weights/icon_caption_florence /app/imgs \
21
- && chown -R 1000:1000 /app
22
 
23
- # Copy application code
24
  COPY main.py utils.py download_models.py ./
25
 
26
- # Download models during build
27
  RUN python download_models.py
28
 
29
- # Set up user for HF Spaces
30
  RUN useradd -m -u 1000 user
31
  USER user
32
  ENV PATH="/home/user/.local/bin:$PATH"
33
 
34
- # Run the application
35
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Base image with CUDA 12.2
2
+ FROM nvidia/cuda:12.2.0-runtime-ubuntu22.04
3
+
4
+ # System dependencies
5
+ RUN apt-get update -q && \
6
+ apt-get install -y --no-install-recommends \
7
+ python3.9 \
8
+ python3-pip \
9
+ libgl1 \
10
  libglib2.0-0 \
11
  wget \
12
  git \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
+ # CUDA/CuDNN setup
16
+ RUN wget -qO /tmp/cuda-keyring.deb \
17
+ https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \
18
+ dpkg -i /tmp/cuda-keyring.deb && \
19
+ apt-get update -q && \
20
+ apt-get install -y --no-install-recommends \
21
+ libcudnn8 \
22
+ libcublas-12-2 && \
23
+ rm -rf /var/lib/apt/lists/*
24
+
25
  WORKDIR /app
26
 
27
+ # Python dependencies
28
  COPY requirements.txt .
29
  RUN pip install --no-cache-dir -r requirements.txt
30
 
31
+ # Create directories
32
+ RUN mkdir -p /app/{weights,imgs} && \
33
+ chmod -R 777 /app
34
 
35
+ # Application code
36
  COPY main.py utils.py download_models.py ./
37
 
38
+ # Download models
39
  RUN python download_models.py
40
 
41
+ # Set up user
42
  RUN useradd -m -u 1000 user
43
  USER user
44
  ENV PATH="/home/user/.local/bin:$PATH"
45
 
 
46
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]