# Chat CAD — Hugging Face Docker Space (Flask + Three.js + torch). # Runs on CPU (free) for the 3D car / parts / drag / crash; set Space hardware to # a GPU (T4) to enable the SDXL photoreal render. torch cu121 wheels bundle the # CUDA runtime, so they use the GPU when one is attached and fall back to CPU when # not — one image works on both. FROM python:3.11-slim WORKDIR /app ENV HOST=0.0.0.0 PORT=7860 PYTHONUNBUFFERED=1 \ HF_HOME=/tmp/hf MPLCONFIGDIR=/tmp/mpl XDG_CACHE_HOME=/tmp/cache # system libs: OpenCascade (cadquery/OCP) needs X11 + GL shared objects RUN apt-get update && apt-get install -y --no-install-recommends \ libgl1 libglu1-mesa libglib2.0-0 \ libxrender1 libxext6 libx11-6 libsm6 libice6 libxi6 \ libfontconfig1 libfreetype6 \ && rm -rf /var/lib/apt/lists/* # torch first (CUDA 12.1 wheels — used on T4, CPU fallback otherwise) RUN pip install --no-cache-dir torch==2.4.0 --index-url https://download.pytorch.org/whl/cu121 # app + diffusion deps. cadquery is required because app.py imports cad_engine at # startup (it has pip wheels now via cadquery-ocp). RUN pip install --no-cache-dir \ "diffusers>=0.30" "transformers>=4.44" "accelerate>=0.33" "safetensors>=0.4" \ "flask>=3.0" "numpy>=1.24,<2" "scipy>=1.11" "matplotlib>=3.7" "Pillow>=10.0" \ "anthropic>=0.40" "google-genai>=0.3" "cadquery>=2.4" "scikit-learn>=1.3" COPY . /app/ RUN mkdir -p /tmp/hf /tmp/mpl /tmp/cache /app/output && chmod -R 777 /tmp/hf /tmp/mpl /app/output EXPOSE 7860 CMD ["python", "app.py"]