Pytorch hangs at Variable when using cuda

Hello I am writing a small pytorch example with a simple NN. The program runs fine if I declare

dtype = torch.FloatTensor
#dtype = torch.cuda.FloatTensor # Uncomment this to run on GPU

The code currently runs great with the CPU option. However, as soon as I uncomment and switch to the GPU option, the code hangs when I call the function

x = Variable(x.type(dtype), requires_grad=True)

The code essentially gets stuck there and stop working.

I have tried to debug this problem. I have confirmed that I have cuda installed
~ $ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Tue_Aug_11_14:27:32_CDT_2015
Cuda compilation tools, release 7.5, V7.5.17

I have confirmed that pytorch can see the cuda

torch.cuda.is_available()
True

I assume I am just missing something small, any help would be appreciated.

The full code can be seen here :

How did you install pytorch? Sometimes a hanging like this can be caused by the version of cuda you have (7.5) not matching the version of cuda used to build pytorch.

1 Like

Interesting

conda list | grep pytorch
cuda75 1.0 hf2493ae_0 pytorch
pytorch 0.1.12 py27cuda8.0cudnn6.0_1

I see that my current pytorch is cuda8.0, which not matching my pytorch 7.5 support. I’ll make this change, thank you very much.