# D1337 CIPHER - Custom Training Environment # Optimized for 4x L40S (192GB VRAM) with QLoRA FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu22.04 # Set environment ENV DEBIAN_FRONTEND=noninteractive ENV PYTHONUNBUFFERED=1 ENV PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512 ENV TOKENIZERS_PARALLELISM=false ENV HF_HOME=/app/.cache/huggingface # Install system dependencies RUN apt-get update && apt-get install -y \ python3.10 \ python3-pip \ python3.10-venv \ git \ git-lfs \ curl \ wget \ && rm -rf /var/lib/apt/lists/* \ && git lfs install # Create user for HuggingFace Spaces RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" WORKDIR /app # Copy requirements first (for caching) COPY --chown=user requirements.txt . # Install Python dependencies RUN pip3 install --no-cache-dir --upgrade pip && \ pip3 install --no-cache-dir -r requirements.txt # Copy application files COPY --chown=user . . # Expose port for Gradio EXPOSE 7860 # Set HuggingFace cache directory RUN mkdir -p /app/.cache/huggingface # Run training script CMD ["python3", "train.py"]