Prerequisites
- Access to NVIDIA DGX Spark Box
- MaxDiffusion source code cloned on the machine (dgx_spark branch)
- Internet connection for Docker build and model downloads
Build Docker image
Create the Dockerfile
In the root directory of your MaxDiffusion project, create a file named This Dockerfile is optimized for build speed by caching dependencies, ensuring code changes don’t require a full reinstall.
box.Dockerfile:Run image generation
Launch container
Start an interactive session with volume mounts:This command:
- Mounts your Hugging Face cache to avoid re-downloading models
- Mounts the output directory for easy access to generated images
Login to Hugging Face (first-time setup)
Inside the Docker container, authenticate with Hugging Face:When prompted:
- Go to huggingface.co/settings/tokens
- Copy your token (or create a new one with write permissions)
- Paste the token into the terminal and press Enter
Retrieve generated images
Find container ID
Open a new terminal (keep the container running). Find your container ID:Look for the container with image
maxdiffusion-arm-gpu and note its ID (e.g., 9049895399fc).Troubleshooting
pip: command not found during Docker build
pip: command not found during Docker build
Cause: The base Docker image doesn’t have pip in the system’s default PATH.Solution: The provided Dockerfile fixes this by installing
python3-pip and using update-alternatives to create symbolic links.externally-managed-environment during pip install
externally-managed-environment during pip install
Cause: Newer versions of Debian/Ubuntu protect system Python packages.Solution: The
ENV PIP_BREAK_SYSTEM_PACKAGES=1 line in the Dockerfile bypasses this protection within the container.OSError: not a valid model identifier
OSError: not a valid model identifier
Cause: The script cannot find models locally and tries to download from Hugging Face.Solution: Launch the container with
-v ~/.cache/huggingface:/root/.cache/huggingface to mount your local model cache.Permission denied when accessing copied files
Permission denied when accessing copied files
Cause: Files copied with
docker cp are owned by root by default.Solution: Run sudo chown your_user:your_user /path/to/file after copying.Out-of-memory (OOM) errors
Out-of-memory (OOM) errors
Problem: Processes require more memory than available RAM.Solution: Add swap memory as a safety net.Create a 64GB swap file:Verify swap is active:
Performance notes
- The DGX Spark ARM architecture provides unique advantages for edge deployment
- Use fused attention via TransformerEngine for optimal GPU performance
- Cache models locally to avoid re-downloading on each run
- Consider swap memory for memory-intensive workloads