-
-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sampling model causes memory to max then crash the os on Linux #1207
Comments
@mike-lawrence can you provide the data in a JSON format rather than the R script? |
Sampling with a single chain avoids a crash, but ram goes to about 26GB (my system has 32GB) and "failed unexpectedly" after two warmup iterations. |
The inner while loop is not being executed in the second iteration of HMC. Not sure why yet, but that's the problem ( |
Adding a bunch of print statements inside the user-defined function, plus sampling with |
Not sure what I did differently, but a second attempt at the above configuration eventually un-hung, returning seemingly successfully but when the |
Oh, if the contents of the TP block are instead put into the model block, the model samples a single chain just fine (notebaly, with only 3Gb RAM usage). If two or more parallel chains are attempted, RAM jumps and at least with the run I just did one of the chains "failed unexpectedly". Could this somehow be a bug related to the writer service receiving quantities that are outputs of a User-defined function (and this specific UDF, as I've written outputs from other UDFs just fine in the past)? Tagging writer expert @mitzimorris in case they have insight here. |
Hm. When varying the seed, for some seeds a single chain finishes ok with reasonable ram usage, and for other seeds it immediately causes ram to explode and yields a "chain finished unexpectedly" result. I'll re-add the prints to see if I can discern if there's a particular area of the parameter space that's pathological. I thought I made the function such that it's guaranteed to exit the while loops regardless of the parameters, but I possibly missed a corner case. |
When running under gdb I definitely ended up stuck in the outer loop. This will keep adding variables to the autodiff stack until you run out of RAM |
Closing as I indeed found the corner case that caused an unterminating while loop. Sorry for the false alarm! |
I'm on Ubuntu 22.04 running cmdstan 2.33.1 with empty makefile. Attached is R code to sample a Stan model's priors, generating synthetic data that is then fed back as data for sampling. The prior sampling and generated data all look ok, but when real sampling happens my RAM balloons rapidly to 100% then Ubuntu crashes.
Further fiddling identifies the following user-defined function as the culprit:
This function runs fine in the GQ block, but when used in the TP block the above noted crash occurs.
The text was updated successfully, but these errors were encountered: