Hello community,
When I get a model on CPU then do model.load_state_dict(torch.load(PATH, map_location=device)) as explained here 15, model.device doesn’t return the device specified in model.load_state_dict(torch.load(PATH, map_location=device)) but “cpu” instead. I then have to perform model.to(device) for it to be on the desired device.
Yet when I load a random Tensor stored on a HDD with my_tensor = torch.load(PATH, map_location=device) then model.device does returns the device specified in torch.load(PATH, map_location=device).
Why is that? Is it load_state_dict that behaves in a special way? Or do I also need to do my_tensor = my_tensor.to(device) after my_tensor = torch.load(PATH, map_location=device)?
And can I do my_tensor = torch.load(PATH, map_location="cpu") then my_tensor = my_tensor.to("cuda:0")? I don’t quite get if both are related or not, if they should be consistent and performed successively or not.
Thanks for the help.