fix broken gputouse by ludovicbellier · Pull Request #2320 · DeepLabCut/DeepLabCut

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