Skip to content

Commit 8f34dd7

Browse files
committed
perf: free unused params immediately to reduce memory usage
1 parent cbee3c9 commit 8f34dd7

File tree

4 files changed

+226
-67
lines changed

4 files changed

+226
-67
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Inference of [Stable Diffusion](https://github.com/CompVis/stable-diffusion) in
1212
- 16-bit, 32-bit float support
1313
- 4-bit, 5-bit and 8-bit integer quantization support
1414
- Accelerated memory-efficient CPU inference
15+
- Only requires ~2.3GB when using txt2img with fp16 precision to generate a 512x512 image
1516
- AVX, AVX2 and AVX512 support for x86 architectures
1617
- Original `txt2img` and `img2img` mode
1718
- Negative prompt
@@ -152,8 +153,8 @@ Using formats of different precisions will yield results of varying quality.
152153
153154
| precision | f32 | f16 |q8_0 |q5_0 |q5_1 |q4_0 |q4_1 |
154155
| ---- | ---- |---- |---- |---- |---- |---- |---- |
155-
| **Disk** | 2.8G | 2.0G | 1.7G | 1.6G | 1.6G | 1.5G | 1.5G |
156-
| **Memory**(txt2img - 512 x 512) | ~4.9G | ~4.1G | ~3.8G | ~3.7G | ~3.7G | ~3.6G | ~3.6G |
156+
| **Disk** | 2.7G | 2.0G | 1.7G | 1.6G | 1.6G | 1.5G | 1.5G |
157+
| **Memory**(txt2img - 512 x 512) | ~2.8G | ~2.3G | ~2.1G | ~2.0G | ~2.0G | ~2.0G | ~2.0G |
157158
158159
159160
## References

main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ int main(int argc, const char* argv[]) {
322322
}
323323
init_img.assign(img_data, img_data + (opt.w * opt.h * c));
324324
}
325-
StableDiffusion sd(opt.n_threads, vae_decode_only);
325+
326+
StableDiffusion sd(opt.n_threads, vae_decode_only, true);
326327
if (!sd.load_from_file(opt.model_path)) {
327328
return 1;
328329
}

0 commit comments

Comments
 (0)