-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
CUDATreeLearner: free GPU memory in destructor if any allocated #4963
Conversation
Ups, seems like some tests are not passing as they are cancelled by timeout. Trying to restart. |
@jmoralez
Thanks 🙏 |
@@ -63,6 +63,43 @@ CUDATreeLearner::CUDATreeLearner(const Config* config) | |||
} | |||
|
|||
CUDATreeLearner::~CUDATreeLearner() { | |||
#pragma omp parallel for schedule(static, num_gpu_) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With a static schedule, and num_gpu_
chunk size, I think there will be only 1 thread being used. So I can we simply remove this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shiyu1994
To be honest I've just copy-pasted code from here which uses omp parallel
, so I decided that probably it is done intentionally. My expectations were that cleanup for each GPU device will be executed in parallel for efficiency (if num_gpu_ > 1
). Do you think we should actually remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After experimenting, I find that schedule(static, num_gpu_) will only result in a single thread. With num_gpu_
block size, and with num_gpu_
total iterations. So this would not parallelize the for loop.
I think it is ok to keep the omp parallel
in this PR. And we can fix this with another PR. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for your contribution!
This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
Fixes memory freeing issue described here: allocated GPU memory is not released after training cycle is complete, which leads to constant memory growth while using multiple train() invocations inside the same process (like hyperparameters search).