hoonsubin commited on
Commit
c984e43
·
1 Parent(s): ce48e72

optimize for cpu again

Browse files
Files changed (2) hide show
  1. .dockerignore +7 -0
  2. Dockerfile +35 -30
.dockerignore ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ node_modules
2
+ __pycache__
3
+ *.pyc
4
+ *.pyo
5
+ *.pyd
6
+ .DS_Store
7
+ .env
Dockerfile CHANGED
@@ -1,8 +1,8 @@
1
- FROM pytorch/pytorch:2.2.2-cuda12.1-cudnn8-devel
2
 
3
  WORKDIR /app
4
 
5
- # Common system dependencies
6
  RUN apt-get update && apt-get install -y \
7
  libportaudio2 \
8
  libportaudiocpp0 \
@@ -10,41 +10,46 @@ RUN apt-get update && apt-get install -y \
10
  libasound-dev \
11
  libsndfile1-dev \
12
  kmod \
13
- && rm -rf /var/lib/apt/lists/*
14
-
15
- # Conditional CUDA configuration for AMD64 only
16
- ARG TARGETARCH
17
- RUN if [ "$TARGETARCH" = "amd64" ]; then \
18
- apt-get update && apt-get install -y \
19
- ocl-icd-opencl-dev \
20
- libopenblas-dev \
21
- && rm -rf /var/lib/apt/lists/*; \
22
- fi
23
-
24
- # Mac-specific audio fixes
25
- RUN if [ "$TARGETARCH" = "arm64" ]; then \
26
- apt-get update && apt-get install -y \
27
  libomp5 \
28
  libopenblas0-pthread \
29
- && rm -rf /var/lib/apt/lists/*; \
30
- fi
 
 
 
 
 
 
 
 
 
 
 
31
 
32
- # Update pip first
33
- RUN pip install --upgrade pip setuptools wheel
 
34
 
35
- # Install base requirements first
36
- RUN pip install numpy==1.26.4
37
 
38
- # Install appropriate PyTorch and TorchAudio versions
39
- RUN if [ "$TARGETARCH" = "amd64" ]; then \
40
- pip install torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cu121; \
41
- else \
42
- pip install torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cpu; \
43
- fi
44
 
45
- # Install remaining requirements
 
 
 
 
 
 
46
  COPY . .
47
- RUN pip install --no-cache-dir -r requirements.txt
 
 
 
 
48
 
49
  EXPOSE 7860
50
  CMD ["python", "app.py"]
 
1
+ FROM python:3.10-slim
2
 
3
  WORKDIR /app
4
 
5
+ # Install system dependencies
6
  RUN apt-get update && apt-get install -y \
7
  libportaudio2 \
8
  libportaudiocpp0 \
 
10
  libasound-dev \
11
  libsndfile1-dev \
12
  kmod \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  libomp5 \
14
  libopenblas0-pthread \
15
+ libgl1 \
16
+ libglib2.0-0 \
17
+ gcc \
18
+ espeak-ng \
19
+ libaio-dev \
20
+ ffmpeg \
21
+ curl \
22
+ build-essential \
23
+ && rm -rf /var/lib/apt/lists/*
24
+
25
+ # Update pip and install base requirements
26
+ RUN pip install --upgrade pip setuptools wheel && \
27
+ pip install numpy==1.26.4
28
 
29
+ # Install CPU-only PyTorch first
30
+ RUN pip install --no-cache-dir torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 \
31
+ --index-url https://download.pytorch.org/whl/cpu
32
 
33
+ # Install CPU-only PyTorch components
34
+ RUN pip install torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cpu
35
 
36
+ # Install Python requirements with CPU-only constraints
37
+ COPY requirements.txt .
38
+ RUN pip install --no-cache-dir -r requirements.txt --no-deps
 
 
 
39
 
40
+ # Fix networkx compatibility
41
+ RUN pip install --force-reinstall networkx==3.2.1
42
+
43
+ # Install unidic for processing Japanese texts
44
+ RUN python -m unidic download
45
+
46
+ # Copy application files
47
  COPY . .
48
+
49
+ # Environment variables for CPU-only operation
50
+ ENV CUDA_VISIBLE_DEVICES=-1 \
51
+ TF_CPP_MIN_LOG_LEVEL=3 \
52
+ SDL_AUDIODRIVER=disk
53
 
54
  EXPOSE 7860
55
  CMD ["python", "app.py"]