The model won't train on GPU

Hi, am new to pytorch and am trying to run my model on GPU, the Jupyter notebook successfully detect my GPU

        if torch.cuda.is_available():
            self.device = torch.device("cuda:0")  # you can continue going on here, like cuda:1 cuda:2....etc. 
            print("Running on the GPU")
            self.device = torch.device("cpu")
            print("Running on the CPU")

Running on the GPU


GeForce RTX 2060

and I used .to(device) for the model and its inputs

self.dqn = Network(states_dim, action_dim).to(self.device)

But it is still working on CPU

Thank you for your help.

The Windows task manager is often nor properly reporting the GPU utilization so you could either select the “compute” output in a drop down menu (I’m no Windows expert as you might notice :wink: ) or use nvidia-smi.

1 Like

Yes, it looks like the task manager isn’t showing the real state of the GPU use. Thank you!
The python.exe is running on GPU but it seems that the GPU is not working at full capacity. is there something wrong or it depends on my model…?

It depends on the model and overall training script. E.g. your data loading might create bottlenecks or the model workload might be too small to properly saturate the GPU.

1 Like