Cuda is available only for a short time after reboot on PyTorch

OS: Ubuntu 18.04
GPU: Nvidia - RTX 2060, NVIDIA-SMI 430.26, Driver Version: 430.26, CUDA Version: 10.2
Laptop: Lenovo Legion Y540

I setup my GPU for PyTorch based on this post:

I have a hybrid setup. Intel Integrated GPU is used for display and NVIDIA for deep learning. Since CUDA comes bundled with PyTorch, I haven’t installed it separately. I have Installed pytorch using: conda install pytorch torchvision cudatoolkit=10.0 -c pytorch.

$ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation Device 3e9b
01:00.0 VGA compatible controller: NVIDIA Corporation Device 1f11 (rev a1)

torch.cuda.is_available() returns True only for a short while after I boot my machine. After that, it returns False.

I don’t understand what the issue is. Cuda seems to available for short window of time after I boot my machine. If I miss that window, I need to reboot to be able to use the GPU in PyTorch. Please help!

Could you check some power settings and make sure the GPU isn’t deactivated to save battery power?

1 Like

I did, I did not find any such setting. In the NVIDIA X Server application, the PRIME profile is set to ‘Intel (power save)’ but that is because I’m using the Intel card for display.
I will experiment some more and see in what cases does this happen. Will update this thread at a later time.