Truncated proposals for SNPE (TSNPE) implementation #1354
Replies: 2 comments
-
Hi there, thanks for raising this! A quick question: What is Also, what is the dimensionality of theta and x? Michael |
Beta Was this translation helpful? Give feedback.
-
in general, when you sample from the posterior that uses a large embedding net / is conditioned on large data, it will generate samples through forward passes through the underlying embedding net and density estimator. Thus, the custom embedding net will always be used. If you draw 1,000,000 samples, these samples will be accumulated on the GPU, which is likely the cause for the out of memory error. Thus, if you really need that many samples, a workaround would be using a for-loop to draw 10 x 100,000 samples, or 100 x 10,000 samples etc. and moving the individual batches to CPU in each iteration. Regarding the device mismatch error after moving the posterior estimator to CPU: you need to make sure that everything lives on the CPU then - the prior, the posterior object, the data, and the net. Ideally, you just create a new
does this help? Cheers, |
Beta Was this translation helpful? Give feedback.
-
Hello,
I have a technical implementation question about truncated proposal for SNPE using the following code from FAQ:
I have implemented the structure above in my workflow. Since I'm using GPU for training, if I do not modify the implementation above,
Drawing 1000000 posterior samples
goes through without any issues, but eventually it throws me an CUDA out-of-memory error. Notably, I see that even RAM and CPU usage also goes up by a lot.I am not sure why the script circles back to our custom defined embedding networks (maybe, that could be the cause of this memory issue, but we're unsure):
However, when I modify my code to move posterior_estimator to CPU, I get a device mismatch error that I cannot easily trace as it goes through different classes of SBI:
I appreciate any thoughts or feedback.
Thank you
Ali
Beta Was this translation helpful? Give feedback.
All reactions