Why does Pytorch need `torch.cuda.is_available()` to be called for it to run?

Viewed 395

This is bugging me as some weird behaviour and I'm hoping someone has met with a similar situation.

Basically my application starts in Nvidia Docker2, and shows the no CUDA-capable device is detected error until I add a line torch.cuda.is_available(), then it magically starts working again.

I've only managed to gather that its not some race condition on what I can control, and calling other cuda runtime commands don't have the same effect.

So now I need to add the line somewhere before I run my pytorch application and I'm baffled as to why?

edit 1: torch.cuda.init() also works, so the question is then why does torch.cuda.is_available() work

0 Answers
Related