Things I want to do
Run Qwen-Image from the command line using stable-diffusion.cpp.
It can run on both AMD GPUs and CPUs.
Environment setup
stable-diffusion.cpp
Download the appropriate Zip file for your environment from the following page.
If you want to run it on an AMD GPU, you need something with ‘vulkan’ or ‘rocm’ in its name.
(Basically, Vulkan should be fine. ROCM will likely have limitations on which GPUs can be used.)

This applies to NVidia GPUs with ‘CUDA’ in their name.
AVX512, AVX2, AVX, and NOAVX are CPU-based. Please check which AVX version is compatible with your CPU and download it. (I was mistaken, but it seems AMD CPUs can also use AVX. It’s easiest to ask an AI which version is compatible.)
Once you’ve extracted the downloaded file to a folder of your choice, you’re ready to go.
Model
Please download the three models one by one from the following pages.
For files that consist of multiple files, larger file sizes require more memory and result in better accuracy.
Please decide which model to use after considering your environment.
In my environment (Ryzen 7 7735HS with Radeon Graphics + 32GB RAM), Qwen_Image-Q8_0.gguf did not work, so I used Qwen_Image-Q4_K_S.gguf instead.
diffusion-model

foot

llm

execution
Launch the command line and navigate to the folder where you extracted stable-diffusion.cpp.
Execute the following command. (Replace the model path with the path to the model you are using.)
sd-cli.exe --diffusion-model Diffusion model path --vae VAE model path --llm llm model path -p 'a cat' --cfg-scale 2.5 --sampling-method euler -v --offload-to-cpu -H 512 -W 512 --diffusion-fa --flow-shift 3
If a cat image is generated in ./output.png, the process was successful.

The official example encloses the prompt in single quotes, like -p a cat , but this won’t work. Please enclose it in double quotes.
Options (arguments)
The options are summarized on the following page.
Only the most commonly used basic ones are listed below.
| -m | Model path |
| -p | prompt |
| -s | Seed value Specify -1 to generate randomly. Please note that if you do not specify a format, the same image will be generated every time. |
-H | Image height |
| -IN | Image width |
--foot | VAE path |
--steps | Step. Initial value: 20 Note that for some models, a lower number may be better. (The official example from Qwen Image was 50.) |
Execution speed
The image generation speed is as follows: (This does not include model loading time or time after iteration.)
| Model | CreationTime(s) |
| stable-diffusion(Vulkan) | 36 |
| Qwen Image(Vulkan) | 623 |
It’s considerably slower compared to StableDiffusion.
error
If you encounter the following error, you are experiencing insufficient memory. Changing the model you are using or closing other applications may resolve the issue.
[ERROR] ggml_extend.hpp:83 - alloc_tensor_range: failed to allocate Vulkan0 buffer of size 1043908608
[ERROR] ggml_extend.hpp:1774 - qwen_image alloc runtime params backend buffer failed, num_tensors = 1933
[ERROR] ggml_extend.hpp:1955 - qwen_image offload params to runtime backend failed
[ERROR] stable-diffusion.cpp:1727 - diffusion model compute failed
[ERROR] stable-diffusion.cpp:1861 - Diffusion model sampling failed
[ERROR] stable-diffusion.cpp:3112 - sampling for image 1/1 failed after 5.14s


コメント