Skip to content

Commit

Permalink
perf: free unused params immediately to reduce memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
leejet committed Aug 16, 2023
1 parent cbee3c9 commit 8f34dd7
Show file tree
Hide file tree
Showing 4 changed files with 226 additions and 67 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Inference of [Stable Diffusion](https://github.com/CompVis/stable-diffusion) in
- 16-bit, 32-bit float support
- 4-bit, 5-bit and 8-bit integer quantization support
- Accelerated memory-efficient CPU inference
- Only requires ~2.3GB when using txt2img with fp16 precision to generate a 512x512 image
- AVX, AVX2 and AVX512 support for x86 architectures
- Original `txt2img` and `img2img` mode
- Negative prompt
Expand Down Expand Up @@ -152,8 +153,8 @@ Using formats of different precisions will yield results of varying quality.
| precision | f32 | f16 |q8_0 |q5_0 |q5_1 |q4_0 |q4_1 |
| ---- | ---- |---- |---- |---- |---- |---- |---- |
| **Disk** | 2.8G | 2.0G | 1.7G | 1.6G | 1.6G | 1.5G | 1.5G |
| **Memory**(txt2img - 512 x 512) | ~4.9G | ~4.1G | ~3.8G | ~3.7G | ~3.7G | ~3.6G | ~3.6G |
| **Disk** | 2.7G | 2.0G | 1.7G | 1.6G | 1.6G | 1.5G | 1.5G |
| **Memory**(txt2img - 512 x 512) | ~2.8G | ~2.3G | ~2.1G | ~2.0G | ~2.0G | ~2.0G | ~2.0G |
## References
Expand Down
3 changes: 2 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ int main(int argc, const char* argv[]) {
}
init_img.assign(img_data, img_data + (opt.w * opt.h * c));
}
StableDiffusion sd(opt.n_threads, vae_decode_only);

StableDiffusion sd(opt.n_threads, vae_decode_only, true);
if (!sd.load_from_file(opt.model_path)) {
return 1;
}
Expand Down
Loading

0 comments on commit 8f34dd7

Please sign in to comment.