Skip to content

Conversation

@ludovicbellier
Copy link
Contributor

Hi @n-poulsen and team DLC!

Here is a PR solving #2312: after TF import (or first call if lazy loading is enabled), os.environ['CUDA_VISIBLE_DEVICES'] has no effect anymore, so I replaced it by tf.config.set_visible_devices() (the TensorFlow equivalent of torch.cuda.set_device() ; hat tip to this message). Also added an explicit error message if gputouse is out of the range of available GPUs.

Made this replacement for all four if gputouse is not None: statements in predict_videos.py, although I only (explicitly) use analyze_videos() (which I just tried, and it worked perfectly!).

Best,
Ludovic

@jeylau jeylau self-requested a review July 24, 2023 08:55
@jeylau
Copy link
Contributor

jeylau commented Jul 24, 2023

Hi @ludovicbellier, thank you very much for the PR! That looks great, I'd only suggest one minor thing though: since lines are repeated across multiple functions, could you maybe put those together into a small function (e.g., set_visible_devices in auxfun_models.py), which is then called where needed?

@MMathisLab MMathisLab requested review from jeylau and n-poulsen and removed request for jeylau July 24, 2023 09:41
@MMathisLab MMathisLab added WORK IN PROGRESS! developers are currently working on this feature... stay tuned. high-priority labels Jul 25, 2023
@jeylau
Copy link
Contributor

jeylau commented Jul 25, 2023

Hope you don't mind @ludovicbellier, I took the liberty to refactor the code myself as we'll merge your PR today. 😊

Copy link
Contributor

@n-poulsen n-poulsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@jeylau jeylau merged commit 3b06cd8 into DeepLabCut:main Jul 25, 2023
@jeylau
Copy link
Contributor

jeylau commented Jul 25, 2023

Thanks @ludovicbellier!

@ludovicbellier
Copy link
Contributor Author

Woops sorry I was gone for a few days, thanks a lot @n-poulsen and @jeylau for the refactoring!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

high-priority WORK IN PROGRESS! developers are currently working on this feature... stay tuned.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants