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
When I load a pre-trained model and push it from GPU->CPU or the vice versa. Certain variables are still projecting in the original device and are not getting pushed to the destination device.
Specifically the "mem" variable under snntorch._neurons.leaky.Leaky
snn_pretrained_model_path = "snn_model.pth"
snn_model.load_state_dict(torch.load(snn_pretrained_model_path))
snn_model.to("cpu") # or "gpu"
What I Did
As a workaround, I deliberately iterate over all the model to find such instances of leaky and push them to the destination device.
if isinstance(layer, nn.Sequential):
for layer_id in range(len(original_dense_model)):
layer = original_dense_model[layer_id]
if isinstance((layer), snntorch._neurons.leaky.Leaky):
layer.mem = layer.mem.to("cpu") # or "gpu" depending on the destination device
else:
for internal_layer in model.modules():
if isinstance((internal_layer), snntorch._neurons.leaky.Leaky):
internal_layer.mem = internal_layer.mem.to("cpu")
The text was updated successfully, but these errors were encountered:
The issue isn't during saving or reloading. However, it is with porting from one device to another, as mentioned above, Certain members of the model aren't getting transferred intrinsically.
Either way, the bug persists. When the model is in memory and is prompted to transfer to a different device (say from GPU to CPU or vice versa) or when the model is loaded from a file. The porting causes the variables to be struck in the original device.
Description
When I load a pre-trained model and push it from GPU->CPU or the vice versa. Certain variables are still projecting in the original device and are not getting pushed to the destination device.
Specifically the "mem" variable under snntorch._neurons.leaky.Leaky
What I Did
As a workaround, I deliberately iterate over all the model to find such instances of leaky and push them to the destination device.
The text was updated successfully, but these errors were encountered: