RuntimeError when putting nn to gpu

net is a neural network I desired,I want to put it to gpu

In the pytorch tutorial,the code is:

but when I run this code,an error occurs:

CUDA error: unknown error

by the way,my cuda is available

so if anyone could help me with this problem,very thx to you

Are you able to create CUDATensors:

x = torch.randn(1, device='cuda')

Also, could you post your current setup, i.e. PyTorch, CUDA, and driver versions?

yes,I’m able to create CUDATensor,my CUDA is available.

my PyTorch version is 1.1,CUDA version is 10.2,my video card is GTX1060(if driver version means this).

strangely,this morning when I ran that code again,there was no error anymore,I am confused.

Oh, maybe your driver was in an invalid state and a restart helped?
Anyway, let us know, if you encounter this error again.

ok,if this error occurs again,I will let you know

thx for help