Stable-Diffusion for Jetson



Jetson Exclusive Docker Setup

For NVIDIA Jetson devices (specifically those running JetPack 6, L4T r36.4.0), a dedicated dockerfile and docker-compose.yaml have been provided to optimize the environment for Jetson architectures.

dockerfile

The Jetson-specific Dockerfile is built on top of nvcr.io/nvidia/l4t-jetpack:r36.4.0 and includes:

  • NVIDIA Jetson Keyrings & Source Lists: Properly configures apt sources for Jetson OTA updates.
  • JetPack Specific PyTorch: Installs PyTorch 2.9.1 and Torchvision 0.24.1 built specially for JetPack 6 (cu126, aarch64).
  • CUDSS: Installs the NVIDIA cuDSS library for accelerated sparse linear solvers on Tegra.
  • User Permissions: Creates a dedicated non-root user basamg and sets up the /workspace directory to avoid running everything as root.

docker-compose.yaml

The accompanying Compose file simplifies the container build and execution:

  • GPU Acceleration: Utilizes the nvidia driver and reserves GPUs to fully enable hardware acceleration capabilities inside the container.
  • Volume Mount: Binds a local ./workspace directory to /workspace within the container for persistent project storage and seamless code editing.
  • Interactive Environment: Exposes port 8888 (which can be used for Jupyter notebooks) and keeps stdin and tty open for interactive terminal sessions using the basamg user.

Step by Step

First of all, you should download the ckpt file to models/ldm/stable-diffusion-v1/model.ckpt

1. Execute Docker Container

$ docker compose build
$ docker compose up -d
$ docker attach jetson_docker

2. Generate Your Images

$ python3 optimizedSD/optimized_txt2img.py --prompt "A highly detailed cinematic portrait of a cybernetic wanderer in a neon-lit futuristic Seoul street, wearing techwear clothing, intricate mechanical details on face, rainy night, reflection on puddles, photorealistic, masterpiece, shot on 35mm lens, sharp focus, depth of field." --H 512 --W 512 --seed 27 --n_iter 1 --n_samples 1 --dim_steps 50

⚠️ Both H and W option must be set to 512.

Results

Below are the images generated based on the provided prompts.

PromptResult
"A highly detailed cinematic portrait of a cybernetic wanderer in a neon-lit futuristic Seoul street, wearing techwear clothing, intricate mechanical details on face, rainy night, reflection on puddles , photorealistic, masterpiece, shot on 35mm lens, sharp focus, depth of field."
Cybernetic wanderer high quality
"A highly detailed cinematic portrait of a cybernetic wanderer in a neon-lit futuristic Seoul street, wearing techwear clothing, intricate mechanical details on face, rainy night, reflection on puddles"
Cybernetic wanderer lower quality
"Korean man, wearing coat jacket, in the coffee shop, drinking ice americano, using transparent straw, highly detailed"
Korean man drinking coffee