You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Variables self.slow_weights are always on cpu.
You can easily fix this by adding a .to() method in Ranger class like so:
def to(self, device):
if device is "cuda":
for i in range(len(self.slow_weights)):
for j, w in enumerate(self.slow_weights[i]):
self.slow_weights[i][j] = w.cuda()
elif device is "cpu":
for i in range(len(self.slow_weights)):
for j, w in enumerate(self.slow_weights[i]):
self.slow_weights[i][j] = w.cpu()
The text was updated successfully, but these errors were encountered:
Are you by any chance creating your Ranger optimizer before moving your model to CUDA?
If so, what you're experiencing is a know error on optimizers that initialize internal state based on the model parameters, like Adagrad, and would be solved just by instantiating your optimizer after you move your model to CUDA.
It's not so common moving the optimizer parameters to cpu/cuda after instantiating them, so I think adding a 'to' method to the optimizer with that purpose, as you suggest, would not be very familiar to regular PyTorch users.
Thanks everyone for the feedback on both sides here. @pabloppp is correct, that PyTorch expects the optimizer to be instantiated after the model is created.
That ordering ensures the correct GPU handling.
Variables self.slow_weights are always on cpu.
You can easily fix this by adding a .to() method in Ranger class like so:
The text was updated successfully, but these errors were encountered: