# Unsloth Studio on AMD GPU (780M)
FROM rocm/pytorch:rocm6.4.2_ubuntu24.04_py3.12_pytorch_release_2.4.1

# Install system dependencies
RUN apt-get update && \
    apt-get install -y curl git wget ffmpeg libglvnd libegl-mesa0 libdrm2

# Install Unsloth Studio with RoCM support
RUN pip install --upgrade pip && \
    pip install unsloth[studio] torch>=2.4.1 && \
    rm -rf /root/.cache/pip

# Set working directory
WORKDIR /app

# Copy application files
COPY . /app/

# Create a volume for persistent storage (weights, checkpoints)
VOLUME ["/data"]

# Environment variables for AMD GPU compatibility
ENV UNSLOTH_ALLOW_XLA=1 \
    PYTORCH_CUDA_ALLOC_FAIL=0

# Run Unsloth Studio with the model path
CMD ["unsloth", "studio", "--cpu", "--gpu", "0", "--model", "/data/my-model"]
