Spaces:
mmb80
/
Running on CPU Upgrade

mmb80 commited on
Commit
bb67b0f
·
verified ·
1 Parent(s): 88b24f5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +39 -54
Dockerfile CHANGED
@@ -1,70 +1,55 @@
1
- # Stage 1: Builder
2
- FROM python:3.12 AS builder
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  WORKDIR /app
5
 
6
- RUN pip install --upgrade pip setuptools wheel
7
-
8
- RUN pip install cmake
9
-
10
- # Install system build dependencies
11
- RUN apt-get clean && apt-get -y update && \
12
- apt-get install -y --no-install-recommends \
13
- build-essential \
14
- cmake \
15
- libopenblas-dev \
16
- liblapack-dev \
17
- libx11-dev \
18
- libpng-dev \
19
- libjpeg-dev \
20
- libtiff-dev && \
21
- rm -rf /var/lib/apt/lists/*
22
-
23
- ENV CMAKE_BUILD_PARALLEL_LEVEL=4
24
-
25
- RUN python -m venv venv
26
- ENV VIRTUAL_ENV=/app/venv
27
- ENV PATH="$VIRTUAL_ENV/bin:$PATH"
28
-
29
- COPY requirements.txt .
30
-
31
- RUN pip install --no-cache-dir -r requirements.txt
32
-
33
- # Stage 2: Runner
34
- FROM python:3.12-slim AS runner
35
-
36
- WORKDIR /app
37
-
38
- # Install runtime dependency: libopenblas.so.0 is provided by libopenblas-base.
39
- RUN apt-get update && \
40
- apt-get install -y --no-install-recommends \
41
- libopenblas0 \
42
- liblapack3 \
43
- libx11-6 \
44
- libpng16-16 \
45
- libjpeg62-turbo \
46
- libtiff6 && \
47
- rm -rf /var/lib/apt/lists/*
48
 
 
49
  ENV HF_HOME=/tmp/huggingface
50
  ENV HUGGINGFACE_HUB_CACHE=/tmp/huggingface
51
  ENV XDG_CACHE_HOME=/tmp/.cache
52
  ENV GRADIO_CACHE_DIR=/tmp/.gradio
53
- ENV GRADIO_EXAMPLES_CACHE=/tmp/.gradio/cached_examples
54
  ENV PYTHONUNBUFFERED=1
55
 
56
- RUN mkdir -p /tmp/model /tmp/huggingface /tmp/.cache /tmp/.gradio /tmp/.gradio/cached_examples \
57
- && chmod -R 777 /tmp/model /tmp/huggingface /tmp/.cache /tmp/.gradio /tmp/.gradio/cached_examples
58
 
59
- COPY --from=builder /app/venv venv
 
60
 
61
- COPY app.py models.py test_functions.py test_compress.py ./
62
- COPY examples/ /app/examples/
63
- COPY assets/ /app/assets/
64
 
65
- ENV VIRTUAL_ENV=/app/venv
66
- ENV PATH="$VIRTUAL_ENV/bin:$PATH"
67
 
 
68
  EXPOSE 7000
69
 
70
- CMD ["python", "app.py"]
 
 
1
+ # Usamos uma imagem oficial da NVIDIA com CUDA 12.1 e Ubuntu 22.04
2
+ FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
3
+
4
+ # Evitar perguntas interativas durante a instalação
5
+ ENV DEBIAN_FRONTEND=noninteractive
6
+
7
+ # Instalar Python 3.12 e dependências do sistema para processamento de imagem (OpenCV/Dlib)
8
+ RUN apt-get update && apt-get install -y --no-install-recommends \
9
+ python3.12 \
10
+ python3.12-venv \
11
+ python3.12-dev \
12
+ python3-pip \
13
+ git \
14
+ cmake \
15
+ build-essential \
16
+ libopenblas-dev \
17
+ liblapack-dev \
18
+ libx11-6 \
19
+ libgl1-mesa-glx \
20
+ libglib2.0-0 \
21
+ && rm -rf /var/lib/apt/lists/*
22
+
23
+ # Definir o Python 3.12 como o comando padrão 'python'
24
+ RUN ln -sf /usr/bin/python3.12 /usr/bin/python3 && ln -sf /usr/bin/python3.12 /usr/bin/python
25
 
26
  WORKDIR /app
27
 
28
+ # Criar e configurar as pastas temporárias com as permissões necessárias para o Hugging Face
29
+ RUN mkdir -p /tmp/model /tmp/huggingface /tmp/.cache /tmp/.gradio \
30
+ && chmod -R 777 /tmp/model /tmp/huggingface /tmp/.cache /tmp/.gradio
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
+ # Definir as variáveis de ambiente para os caches e execução
33
  ENV HF_HOME=/tmp/huggingface
34
  ENV HUGGINGFACE_HUB_CACHE=/tmp/huggingface
35
  ENV XDG_CACHE_HOME=/tmp/.cache
36
  ENV GRADIO_CACHE_DIR=/tmp/.gradio
 
37
  ENV PYTHONUNBUFFERED=1
38
 
39
+ # Atualizar ferramentas de instalação
40
+ RUN pip install --no-cache-dir --upgrade pip setuptools wheel
41
 
42
+ # Copiar o requirements.txt (usa a versão sem o sufixo +cpu que enviei antes)
43
+ COPY requirements.txt .
44
 
45
+ # Instalar as bibliotecas Python (o PyTorch será instalado com suporte CUDA automaticamente)
46
+ RUN pip install --no-cache-dir -r requirements.txt
 
47
 
48
+ # Copiar o resto do código do projeto para dentro da imagem
49
+ COPY . .
50
 
51
+ # Porta usada pelo Gradio (conforme configurado no teu app.py)
52
  EXPOSE 7000
53
 
54
+ # Comando para iniciar o servidor
55
+ CMD ["python", "app.py"]