Spaces:
No application file
No application file
| FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu20.04 | |
| WORKDIR /app | |
| # Set environment variables | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| DEBIAN_FRONTEND=noninteractive \ | |
| TRANSFORMERS_CACHE=/app/.cache/transformers \ | |
| HF_HOME=/app/.cache/huggingface \ | |
| TORCH_HOME=/app/.cache/torch \ | |
| HF_DATASETS_CACHE=/app/.cache/datasets | |
| # Install basic dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| python3.9 \ | |
| python3.9-dev \ | |
| python3-pip \ | |
| python3-setuptools \ | |
| git \ | |
| wget \ | |
| curl \ | |
| ca-certificates \ | |
| build-essential \ | |
| && apt-get clean \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create symbolic link for python | |
| RUN ln -sf /usr/bin/python3.9 /usr/bin/python | |
| # Upgrade pip | |
| RUN python3.9 -m pip install --no-cache-dir --upgrade pip | |
| # Create cache directories | |
| RUN mkdir -p /app/.cache/transformers \ | |
| /app/.cache/huggingface \ | |
| /app/.cache/torch \ | |
| /app/.cache/datasets | |
| # Install PyTorch with CUDA support | |
| RUN pip install --no-cache-dir torch==2.0.0 torchvision==0.15.1 torchaudio==2.0.1 --extra-index-url https://download.pytorch.org/whl/cu118 | |
| # Install latest version of transformers that includes Cache class | |
| RUN pip install --no-cache-dir transformers>=4.34.0 | |
| # Clone and install LAVIS properly | |
| RUN git clone https://github.com/salesforce/LAVIS.git \ | |
| && cd LAVIS \ | |
| && sed -i '/open3d/d' requirements.txt \ | |
| && sed -i 's/transformers.*//' requirements.txt \ | |
| && python3.9 -m pip install --no-cache-dir -e . | |
| # Copy requirements files and install dependencies | |
| # Note: We'll install without replacing transformers | |
| COPY requirements_lavis.txt requirements_emo.txt ./ | |
| RUN pip install --no-cache-dir --no-deps -r requirements_lavis.txt -r requirements_emo.txt | |
| # Copy application files | |
| COPY app.py ./ | |
| COPY blip2_vicuna_instruct.py ./LAVIS/lavis/models/blip2_models/ | |
| COPY static/ ./static/ | |
| COPY templates/ ./templates/ | |
| COPY start.sh ./ | |
| RUN chmod +x ./start.sh | |
| # Create directory for model weights | |
| RUN mkdir -p /app/LAVIS/lavis/weight/vicuna-7b-2/ | |
| # Set up a volume for persistent cache | |
| VOLUME /app/.cache | |
| # Set the default command to run the Flask app | |
| CMD ["./start.sh"] |