FROM nvidia/cuda:12.1.0-devel-ubuntu22.04 # Set environment variables ENV DEBIAN_FRONTEND=noninteractive ENV PYTHONUNBUFFERED=1 ENV HF_HOME=/app/.cache/huggingface ENV TRANSFORMERS_CACHE=/app/.cache/huggingface/transformers # Install system dependencies RUN apt-get update && apt-get install -y \ python3.11 \ python3.11-dev \ python3-pip \ git \ wget \ curl \ ninja-build \ && rm -rf /var/lib/apt/lists/* # Set Python 3.11 as default RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 # Upgrade pip RUN pip3 install --upgrade pip setuptools wheel # Install PyTorch with CUDA 12.1 RUN pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 # Install core ML packages RUN pip3 install \ transformers>=4.36.0 \ accelerate>=0.25.0 \ datasets>=2.16.0 \ peft>=0.7.0 \ trl>=0.7.0 \ bitsandbytes>=0.41.0 \ huggingface_hub>=0.20.0 # Install Flash Attention 2 RUN pip3 install flash-attn --no-build-isolation # Install DeepSpeed for distributed training RUN pip3 install deepspeed # Install additional utilities RUN pip3 install \ einops \ sentencepiece \ protobuf \ scipy \ wandb \ tensorboard \ tqdm # Set working directory WORKDIR /app # Copy application files COPY . /app/ # Create cache directories RUN mkdir -p /app/.cache/huggingface # Set entrypoint CMD ["python3", "app.py"]