NLPGenius commited on
Commit
d1fffc3
·
1 Parent(s): faca925

Fix Dockerfile for Hugging Face Spaces compatibility

Browse files
Files changed (2) hide show
  1. Dockerfile +12 -21
  2. requirements.txt +2 -1
Dockerfile CHANGED
@@ -1,19 +1,4 @@
1
- FROM nvidia/cuda:11.8-devel-ubuntu22.04
2
-
3
- # Install Python 3.11
4
- RUN apt-get update && apt-get install -y \
5
- software-properties-common \
6
- && add-apt-repository ppa:deadsnakes/ppa \
7
- && apt-get update && apt-get install -y \
8
- python3.11 \
9
- python3.11-pip \
10
- python3.11-dev \
11
- build-essential \
12
- && rm -rf /var/lib/apt/lists/*
13
-
14
- # Set Python 3.11 as default
15
- RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
16
- RUN update-alternatives --install /usr/bin/pip3 pip3 /usr/bin/pip3.11 1
17
 
18
  # Set environment variables for GPU optimization
19
  ENV PYTHONUNBUFFERED=1
@@ -21,15 +6,21 @@ ENV PYTHONDONTWRITEBYTECODE=1
21
  ENV PIP_NO_CACHE_DIR=1
22
  ENV PIP_DISABLE_PIP_VERSION_CHECK=1
23
  ENV CUDA_VISIBLE_DEVICES=0
24
- ENV TORCH_CUDA_ARCH_LIST="6.0;6.1;7.0;7.5;8.0;8.6"
25
 
26
  WORKDIR /code
27
 
 
 
 
 
 
 
 
28
  # Copy and install requirements first (for better caching)
29
  COPY ./requirements.txt /code/requirements.txt
30
- RUN pip3 install --no-cache-dir --upgrade pip && \
31
- pip3 install --no-cache-dir -r /code/requirements.txt && \
32
- python3 -c "import nltk; nltk.download('punkt', quiet=True); nltk.download('stopwords', quiet=True)"
33
 
34
  # Copy application files
35
  COPY . .
@@ -41,5 +32,5 @@ RUN mkdir -p /.cache .chroma /root/.cache/huggingface && \
41
  # Expose port
42
  EXPOSE 7860
43
 
44
- # Use exec form with GPU-optimized settings
45
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
 
1
+ FROM python:3.11-slim
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  # Set environment variables for GPU optimization
4
  ENV PYTHONUNBUFFERED=1
 
6
  ENV PIP_NO_CACHE_DIR=1
7
  ENV PIP_DISABLE_PIP_VERSION_CHECK=1
8
  ENV CUDA_VISIBLE_DEVICES=0
 
9
 
10
  WORKDIR /code
11
 
12
+ # Install system dependencies efficiently
13
+ RUN apt-get update && apt-get install -y \
14
+ --no-install-recommends \
15
+ build-essential \
16
+ wget \
17
+ && rm -rf /var/lib/apt/lists/*
18
+
19
  # Copy and install requirements first (for better caching)
20
  COPY ./requirements.txt /code/requirements.txt
21
+ RUN pip install --no-cache-dir --upgrade pip && \
22
+ pip install --no-cache-dir -r /code/requirements.txt && \
23
+ python -c "import nltk; nltk.download('punkt', quiet=True); nltk.download('stopwords', quiet=True)"
24
 
25
  # Copy application files
26
  COPY . .
 
32
  # Expose port
33
  EXPOSE 7860
34
 
35
+ # Use exec form with optimized settings
36
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
requirements.txt CHANGED
@@ -7,7 +7,8 @@ langchain-core==0.2.38
7
  langchain-openai==0.1.25
8
  rank_bm25==0.2.2
9
  transformers==4.42.0
10
- torch==2.1.0+cu118 --index-url https://download.pytorch.org/whl/cu118
 
11
  accelerate==0.24.1
12
  sentence-transformers==2.2.2
13
  python-dotenv==1.0.0
 
7
  langchain-openai==0.1.25
8
  rank_bm25==0.2.2
9
  transformers==4.42.0
10
+ torch==2.1.0
11
+ torchaudio==2.1.0
12
  accelerate==0.24.1
13
  sentence-transformers==2.2.2
14
  python-dotenv==1.0.0