Thanks for your reply. Actually I’ve already checked torch.cuda.is_available() and the return is True, so I omit it from my code.
What I do not understand is that, my CPU gets 100% when running the code and I can hardly do others things on my computer:( but my GPU is empty.
Also somebody told me that this code is quite efficient running on his computers as the loss drop fast, while mine seems to be useless. Changing learning_rate does not help.