# Minimal base image - optimized for size and build speed FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 ENV DEBIAN_FRONTEND=noninteractive ENV CUDA_HOME=/usr/local/cuda ENV PATH=${CUDA_HOME}/bin:${PATH} ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} # Only build for T4 (7.5) and A100 (8.0) - HuggingFace hardware ENV TORCH_CUDA_ARCH_LIST="7.5;8.0" # Install minimal runtime dependencies # Remove problematic CUDA repo and install packages RUN rm -f /etc/apt/sources.list.d/cuda*.list /etc/apt/sources.list.d/*.list && \ apt-get update && apt-get install -y --no-install-recommends --allow-unauthenticated \ ca-certificates \ && apt-get clean && rm -rf /var/lib/apt/lists/* && \ apt-get update && apt-get install -y --no-install-recommends \ python3.10 \ python3-pip \ git \ libgl1 \ libglib2.0-0 \ libgomp1 \ && rm -rf /var/lib/apt/lists/* \ && apt-get clean # Set python as default RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 && \ update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 # Upgrade pip RUN python3 -m pip install --no-cache-dir --upgrade pip WORKDIR /app # Install PyTorch (smallest CUDA 11.8 build) RUN pip install --no-cache-dir torch==2.1.0 torchvision==0.16.0 --index-url https://download.pytorch.org/whl/cu118 # Copy and install only essential requirements COPY requirements.txt . RUN pip install --no-cache-dir \ gradio>=4.0.0 \ numpy>=1.24.0 \ opencv-python-headless>=4.8.0 \ Pillow>=10.0.0 \ huggingface-hub>=0.20.0 \ && pip cache purge # Clone FoundationPose (but don't build yet - that's done in final stage) RUN git clone --depth 1 https://github.com/NVlabs/FoundationPose.git /app/FoundationPose && \ cd /app/FoundationPose/bundlesdf/mycuda && \ sed -i 's/-std=c++14/-std=c++17/g' setup.py # Copy application files COPY app.py client.py estimator.py ./ # Create weights directory RUN mkdir -p weights EXPOSE 7860