
!https://raw.githubusercontent.com/dusty-nv/jetson-containers/docs/docs/images/diffusion_astronaut.jpg
本Docker镜像基于Stable Diffusion实现,支持通过文本生成图像(txt2img)或通过图像生成图像(img2img)。集成了CompVis的stable-diffusion代码(/opt/stable-diffusion)和basujindal的内存优化版本(/opt/stable-diffusion/optimizedSD),已在stable-diffusion-1.4模型上测试通过。适用于Jetson设备,提供命令行方式的图像生成功能。
如需带Web界面的更快实现,可参考https://github.com/dusty-nv/jetson-containers/tree/master/packages/diffusion/stable-diffusion-webui%E5%AE%B9%E5%99%A8%E3%80%82
stable-diffusion-1.4模型(可从Hugging Face获取)L4T >=34.1.0,即JetPack 5.1+)适用于在Jetson嵌入式设备上进行AI图像生成的场景,包括:
1. 下载模型
首先下载stable-diffusion-1.4模型文件(sd-v1-4.ckpt):
bashwget https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt -O /data/models/stable-diffusion/sd-v1-4.ckpt
2. 基础生成命令
默认生成6张512x512图像,使用50步优化:
bashcd /opt/stable-diffusion && python3 scripts/txt2img.py --plms \ --ckpt /data/models/stable-diffusion/sd-v1-4.ckpt \ --outdir /data/images/stable-diffusion \ --prompt "a photograph of an astronaut riding a horse"
3. 自定义参数生成
生成1张512x512图像,使用25步优化:
bashcd /opt/stable-diffusion && python3 scripts/txt2img.py --plms \ --n_samples 1 --n_iter 1 --ddim_steps 25 \ --ckpt /data/models/stable-diffusion/sd-v1-4.ckpt \ --outdir /data/images/stable-diffusion \ --prompt "two robots walking in the woods"
主要参数说明:
--W/--H:图像宽度/高度(默认512x512)--seed:随机种子(默认42,不同种子生成不同结果)--n_samples:每轮生成图像数量--n_iter:生成轮数--ddim_steps:优化步数(影响质量和速度)4. 低内存设备优化(Jetson Orin Nano)
使用内存优化版本脚本:
bashcd /opt/stable-diffusion && python3 optimizedSD/optimized_txt2img.py \ --sampler plms --seed 42 \ --n_samples 1 --n_iter 1 --ddim_steps 25 \ --ckpt /data/models/stable-diffusion/sd-v1-4.ckpt \ --outdir /data/images/stable-diffusion \ --prompt "a photograph of an astronaut riding a horse"
5. 脚本化运行
完整流程可通过脚本执行:https://github.com/dusty-nv/jetson-containers/tree/master/packages/diffusion/stable-diffusion/test.sh
stable-diffusion | |
|---|---|
| 构建状态 | |
| 系统要求 | L4T ['>=34.1.0'](JetPack 5.1+) |
| 依赖项 | https://github.com/dusty-nv/jetson-containers/tree/master/packages/build/build-essential%E3%80%81https://github.com/dusty-nv/jetson-containers/tree/master/packages/cuda/cuda%E3%80%81https://github.com/dusty-nv/jetson-containers/tree/master/packages/cuda/cudnn%E3%80%81https://github.com/dusty-nv/jetson-containers/tree/master/packages/build/python%E3%80%81https://github.com/dusty-nv/jetson-containers/tree/master/packages/numpy%E3%80%81https://github.com/dusty-nv/jetson-containers/tree/master/packages/build/cmake/cmake_pip%E3%80%81https://github.com/dusty-nv/jetson-containers/tree/master/packages/onnx%E3%80%81https://github.com/dusty-nv/jetson-containers/tree/master/packages/pytorch%E3%80%81https://github.com/dusty-nv/jetson-containers/tree/master/packages/pytorch/torchvision%E3%80%81https://github.com/dusty-nv/jetson-containers/tree/master/packages/llm/huggingface_hub%E3%80%81https://github.com/dusty-nv/jetson-containers/tree/master/packages/build/rust%E3%80%81https://github.com/dusty-nv/jetson-containers/tree/master/packages/llm/transformers |
| 依赖容器 | https://github.com/dusty-nv/jetson-containers/tree/master/packages/l4t/l4t-diffusion |
| Dockerfile | https://github.com/dusty-nv/jetson-containers/tree/master/packages/diffusion/stable-diffusion/Dockerfile |
| 镜像标签 | https://hub.docker.com/r/dustynv/stable-diffusion/tags (2023-12-14, 6.1GB)https://hub.docker.com/r/dustynv/stable-diffusion/tags (2023-12-12, 6.1GB)https://hub.docker.com/r/dustynv/stable-diffusion/tags (2023-12-15, 6.1GB) |
| 注意事项 | JetPack 4上不支持 |
| 仓库/标签 | 日期 | 架构 | 大小 |
|---|---|---|---|
| https://hub.docker.com/r/dustynv/stable-diffusion/tags | 2023-12-14 | arm64 | 6.1GB |
| https://hub.docker.com/r/dustynv/stable-diffusion/tags | 2023-12-12 | arm64 | 6.1GB |
| https://hub.docker.com/r/dustynv/stable-diffusion/tags | 2023-12-15 | arm64 | 6.1GB |
容器镜像与其他次要版本的JetPack/L4T兼容:
• L4T R32.7容器可在其他L4T R32.7版本(JetPack 4.6+)上运行
• L4T R35.x容器可在其他L4T R35.x版本(JetPack 5.1+)上运行
可使用https://github.com/dusty-nv/jetson-containers/tree/master/docs/run.md%E5%92%8Chttps://github.com/dusty-nv/jetson-containers/tree/master/docs/run.md#autotag%E5%90%AF%E5%8A%A8%E5%AE%B9%E5%99%A8%EF%BC%8C%E6%88%96%E6%89%8B%E5%8A%A8%E6%9E%84%E9%80%A0%60docker run`命令:
bash# 自动拉取或构建兼容的容器镜像 jetson-containers run $(autotag stable-diffusion) # 或显式指定上述镜像之一 jetson-containers run dustynv/stable-diffusion:r35.4.1 # 或使用'docker run'(指定镜像和挂载等) sudo docker run --runtime nvidia -it --rm --network=host dustynv/stable-diffusion:r35.4.1
https://github.com/dusty-nv/jetson-containers/tree/master/docs/run.md 将参数转发给
docker run,并添加一些默认值(如--runtime nvidia、挂载/data缓存、检测设备)
https://github.com/dusty-nv/jetson-containers/tree/master/docs/run.md#autotag 查找与JetPack/L4T版本兼容的容器镜像——本地镜像、从仓库拉取或构建镜像。
使用-v或--volume标志将本地目录挂载到容器中:
bashjetson-containers run -v /本地路径:/容器内路径 $(autotag stable-diffusion)
bashjetson-containers run $(autotag stable-diffusion) my_app --abc xyz
可传递任何docker run支持的选项,执行前会打印完整命令。
如果使用上述https://github.com/dusty-nv/jetson-containers/tree/master/docs/run.md#autotag%EF%BC%8C%E9%9C%80%E8%A6%81%E6%97%B6%E4%BC%9A%E8%87%AA%E5%8A%A8%E6%9E%84%E5%BB%BA%E5%AE%B9%E5%99%A8%E3%80%82%E8%A6%81%E6%89%8B%E5%8A%A8%E6%9E%84%E5%BB%BA%EF%BC%8C%E5%85%88%E5%AE%8C%E6%88%90https://github.com/dusty-nv/jetson-containers/tree/master/docs/setup.md%EF%BC%8C%E7%84%B6%E5%90%8E%E8%BF%90%E8%A1%8C%EF%BC%9A
bashjetson-containers build stable-diffusion
构建过程中会集成上述依赖项并进行测试。使用https://github.com/dusty-nv/jetson-containers/tree/master/jetson_containers/build.py%E6%9F%A5%E7%9C%8B%E6%9E%84%E5%BB%BA%E9%80%89%E9%A1%B9%E3%80%82
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。





探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务