Spaces:
Runtime error
Runtime error
| # Use NVIDIA CUDA base image with Python 3.10 and CUDA 11.6 | |
| # Use CUDA 11.6 base image | |
| FROM nvidia/cuda:11.6.2-cudnn8-runtime-ubuntu20.04 | |
| # Set environment variables | |
| ENV DEBIAN_FRONTEND=noninteractive \ | |
| PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| PIP_DISABLE_PIP_VERSION_CHECK=1 \ | |
| PIP_DEFAULT_TIMEOUT=100 \ | |
| LD_LIBRARY_PATH=/usr/local/cuda-11.6/lib64:$LD_LIBRARY_PATH \ | |
| NVIDIA_VISIBLE_DEVICES=all \ | |
| NVIDIA_DRIVER_CAPABILITIES=compute,utility \ | |
| GRADIO_SERVER_PORT=7860 | |
| # Install system dependencies, Python 3.10, and build tools | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| software-properties-common \ | |
| && add-apt-repository ppa:deadsnakes/ppa -y \ | |
| && apt-get update \ | |
| && apt-get install -y --no-install-recommends \ | |
| # Python 3.10 and tools | |
| python3.10 python3.10-venv python3.10-dev \ | |
| # Build dependencies for Python packages and SQLite | |
| build-essential cmake gcc g++ git curl wget tcl \ | |
| # Math libraries | |
| libopenblas-dev libopenmpi-dev libomp-dev \ | |
| # For data processing | |
| libffi-dev libssl-dev \ | |
| # Clean up | |
| && rm -rf /var/lib/apt/lists/* \ | |
| && apt-get clean | |
| # Download, compile, and install SQLite | |
| RUN wget -O /tmp/sqlite.tar.gz https://www.sqlite.org/2022/sqlite-autoconf-3400100.tar.gz \ | |
| && mkdir -p /tmp/sqlite \ | |
| && tar xzf /tmp/sqlite.tar.gz -C /tmp/sqlite --strip-components=1 \ | |
| && cd /tmp/sqlite \ | |
| && ./configure --prefix=/usr/local \ | |
| && make -j$(nproc) \ | |
| && make install \ | |
| && ldconfig \ | |
| && rm -rf /tmp/sqlite /tmp/sqlite.tar.gz | |
| # Set Python 3.10 as default and install pip | |
| RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 \ | |
| && update-alternatives --install /usr/bin/python python /usr/bin/python3 1 \ | |
| && curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 | |
| # Set environment variables for ChromaDB and pysqlite3 | |
| ENV LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH} \ | |
| PYSQLITE3_BUNDLED=1 \ | |
| CFLAGS="-DSQLITE_MAX_VARIABLE_NUMBER=250000 -DSQLITE_MAX_EXPR_DEPTH=10000" | |
| # Install pysqlite3 from source and other base python packages | |
| RUN python3 -m pip install --no-cache-dir --upgrade setuptools wheel \ | |
| && python3 -m pip install --no-cache-dir --no-binary pysqlite3 pysqlite3 | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy requirements first to leverage Docker cache | |
| COPY requirements.txt . | |
| # Install PyTorch with CUDA 11.6 support first | |
| RUN python3 -m pip install --no-cache-dir \ | |
| torch==1.13.1+cu116 \ | |
| torchvision==0.14.1+cu116 \ | |
| torchaudio==0.13.1 \ | |
| --extra-index-url https://download.pytorch.org/whl/cu116 | |
| # Install remaining requirements | |
| RUN python3 -m pip install --no-cache-dir -r requirements.txt | |
| # Verify PyTorch installation with CUDA | |
| RUN python3 -c "import torch; print(f'PyTorch version: {torch.__version__}'); print(f'CUDA available: {torch.cuda.is_available()}'); print(f'CUDA version: {torch.version.cuda}')" | |
| # Copy application code | |
| COPY . . | |
| # Remove any existing database directory to ensure a fresh start | |
| RUN rm -rf ./chroma_db | |
| # Expose the port Gradio runs on | |
| EXPOSE 7860 | |
| # Download the sentence transformer model during build | |
| RUN python3 -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('pritamdeka/S-Biomed-Roberta-snli-multinli-stsb')" | |
| # Default command to run the app | |
| CMD ["python3", "app.py"] |