Pytorch cuda get_device_name and current_device() hang and are killed?

Viewed 5409

I've just installed a new GPU (RTX 2070) in my machine alongside the old GPU. I wanted to see if PyTorch picked up it, so following the instructions here: How to check if pytorch is using the GPU?, I ran the following commands (Python3.6.9, Linux Mint Tricia 19.3)

>>> import torch
>>> torch.cuda.is_available()
True
>>> torch.cuda.current_device()
Killed
>>> torch.cuda.get_device_name(0)
Killed

Both of the two Killed processes took some time and one of them froze the machine for half a minute or so. Does anyone have any experience with this? Are there some setup steps I'm missing?

2 Answers

If I understand correctly, you would like to list the available cuda devices. This can be done via nvidia-smi (not a PyTorch function), and both your old GPU and the RTX 2070 should show up, as devices 0 and 1. In PyTorch, if you want to pass data to one specific device, you can do device = torch.device("cuda:0") for GPU 0 and device = torch.device("cuda:1") for GPU 1. While running, you can do nvidia-smi to check the memory usage & running processes for each GPU.

Related