Commit 04a4439
authored
[Common] Help gc to collect unused model outputs (#3643)
### Changes
Variable which is containing model outputs during statistic collection
is explicitly freed after each iteration
### Reason for changes
The quantization cell was failing on my machine with 125GB of RAM in the
[SD v3 TorchFX
notebook](https://github.com/openvinotoolkit/openvino_notebooks/blob/latest/notebooks/stable-diffusion-v3-torch-fx/stable-diffusion-v3-torch-fx.ipynb).
After checking that the pytorch code is not leaking by the [pytorch
profiler tool](https://docs.pytorch.org/docs/stable/profiler)
<img width="1870" height="1145" alt="image"
src="https://github.com/user-attachments/assets/dba21040-8455-49b3-84fa-74e9aa3f9fd8"
/>
I confirmed that the problem is not related to statistic collection
directly. After that I forced the garbage collection by the `del`
statement - and my memory didn't exceed healthy 50GB during the runtime,
and SQ was successfully applied to the model (in contrast with previous
runs)
### Related tickets
### Tests
I'm not sure which test should I do with that1 parent 58d8d8c commit 04a4439
1 file changed
+5
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
89 | 94 | | |
90 | 95 | | |
91 | 96 | | |
| |||
0 commit comments