Solved by Kaneda in post #5 
              
              
                Found a solution 
device = 'cuda' if torch.cuda.is_available() else 'cpu' 
My pc froze a bit but finally it gave my desired output. 
idk what happened and why torch.device isnt working tho…