Skip to content

Commit 55a5011

Browse files
authored
Update dgx_spark.md
1 parent f92267c commit 55a5011

1 file changed

Lines changed: 32 additions & 15 deletions

File tree

docs/dgx_spark.md

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
# MaxDiffusion on DGX Spark GPU: A complete User Guide
1+
# MaxDiffusion on Nvidia DGX Spark GPU: A complete User Guide
22

3-
This guide provides a detailed step-by-step walkthrough for setting up and running the maxdiffusion library within a custom Docker environment on an ARM-based machine with NVIDIA GPU support (like a spark VM). We will cover everything from building the optimized Docker image to generating your first image and retrieving it successfully.
3+
This guide provides a detailed step-by-step walkthrough for setting up and running the maxdiffusion library within a custom Docker environment on an ARM-based machine with NVIDIA GPU support. We will cover everything from building the optimized Docker image to generating your first image and retrieving it successfully.
44

55
## Prerequisites
66

77
Before you begin, ensure you have the following:
88

9-
- Access to an ARM-based Linux machine (e.g., your spark VM) with Docker installed.
10-
- NVIDIA GPU drivers and the NVIDIA Container Toolkit installed on the host machine to enable `--gpus all` support.
9+
- Access to [Nvidia DGX Spark Box](https://www.nvidia.com/en-us/products/workstations/dgx-spark/).
1110
- The maxdiffusion source code cloned onto the machine.
1211
- Branch: dgx_spark
13-
- A requirements.txt file in the root of the maxdiffusion directory
1412
- An internet connection for the initial Docker build and for downloading models (if not cached).
1513

1614
## Part 1: Building the Optimized Docker Image
@@ -22,7 +20,8 @@ The foundation of a smooth workflow is a well-built Docker image. The following
2220
In the root directory of your maxdiffusion project, create a file named box.Dockerfile and paste the following content into it.
2321

2422
```docker
25-
# Base image for ARM64 with CUDA support
23+
# Nvidia Base image for ARM64 with CUDA support
24+
# As JAX AI Image as it currently doesn't support ARM builds.
2625
FROM nvcr.io/nvidia/cuda-dl-base@sha256:3631d968c12ef22b1dfe604de63dbc71a55f3ffcc23a085677a6d539d98884a4
2726
2827
# Set environment variables (these rarely change)
@@ -65,27 +64,27 @@ CMD ["/bin/bash"]
6564

6665
### Step2: Build the Image
6766

68-
Open your terminal on the spark VM, navigate to the root directory of the maxdiffusion project, and run the build command:
67+
Open your terminal on DGX Spark, navigate to the root directory of the maxdiffusion project, and run the build command:
6968

7069
```bash
7170
docker build -f box.Dockerfile -t maxdiffusion-arm-gpu .
7271
```
7372

74-
This command will execute the steps in your Dockerfile, download the necessary layers, install all dependencies, and create a local Docker image named maxdiffusion-arm-gpu. The first build may take some time. Subsequent builds will be much faster if you only change the source code.
73+
This command will execute the steps in your Dockerfile, download the necessary layers, install all dependencies, and create a local Docker image named `maxdiffusion-arm-gpu`. The first build may take some time. Subsequent builds will be much faster if you only change the source code.
7574

7675
## Part 2: Running the Container for Image Generation
7776

7877
To run the image generator effectively, we need to connect our local machine's folders to the container. This prevents re-downloading models and makes it easy to retrieve the output images.
7978

8079
### Step 1: Create a Local Output Directory
8180

82-
On your spark VM, create a directory to store the generated images.
81+
On your DGX Spark, create a directory to store the generated images.
8382

8483
```bash
8584
mkdir -p ~/maxdiffusion_output
8685
```
8786

88-
### Step 2: Launch the Container with Volume Mounts
87+
### Step 2a: Launch the Container with Volume Mounts
8988

9089
Run the following command to start an interactive session inside your container. This command links your Hugging Face cache (to avoid re-downloading models) and the output directory you just created.
9190

@@ -97,6 +96,24 @@ maxdiffusion-arm-gpu
9796
```
9897
Your terminal prompt will change, indicating you are now inside the running container.
9998

99+
#### Step 2b: Log in to Hugging Face (First-Time Setup)
100+
101+
You must do this once to download the required model weights.
102+
103+
```bash
104+
# [Inside the Docker Container]
105+
huggingface-cli login
106+
```
107+
108+
You will be prompted to paste a Hugging Face User Access Token.
109+
110+
1. Go to[ huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) in your web browser.
111+
112+
2. Copy your token (or create a new one with write permissions).
113+
114+
3. Paste the token into the terminal and press Enter.
115+
116+
100117
## Part 3: Generating Your First Image
101118

102119
Now that you are inside the container's interactive shell, you can execute the image generation script. Run the following command:
@@ -112,30 +129,30 @@ The generation script saves the final image to its working directory (/app) insi
112129

113130
### Step 1: Copy the Image from Container to VM
114131

115-
Open a new terminal window and connect to your spark VM. Do not close the terminal where the container is running.
132+
Open a new terminal window. Do not close the terminal where the container is running.
116133
First, find your container's ID:
117134

118135
```bash
119136
docker ps
120137
```
121138

122139
Look for the container with the image maxdiffusion-arm-gpu and note its ID (e.g., 9049895399fc).
123-
Now, copy the image from the container to a temporary location on the VM and fix its permissions.
140+
Now, copy the image from the container to a temporary location on DGX Spark and fix its permissions.
124141

125142
```bash
126143
# Copy the file to the /tmp/ directory on the VM
127144
docker cp 9049895399fc:/app/flux_0.png /tmp/flux_0.png
128145

129146
# Change the file's owner to your user to avoid permission errors
130-
sudo chown parambole:parambole /tmp/flux_0.png
147+
sudo chown username:username /tmp/flux_0.png
131148
```
132149

133150
### Step 2: Copy the Image from VM to Your MAC
134151

135-
Now, open the Terminal app on your Mac and use the scp (secure copy) command to download the file from the VM.
152+
Now, open the Terminal app on your Laptop and use the scp (secure copy) command to download the file from DGX Spark.
136153

137154
```bash
138-
scp parambole@spark:/tmp/flux_0.png .
155+
scp username@spark:/tmp/flux_0.png .
139156
```
140157

141158
This command will download flux_0.png to the current directory on your Mac. You can now view your generated image!

0 commit comments

Comments
 (0)