TypeError: cannot assign 'torch.cuda.FloatTensor' as parameter 'weight' (torch.nn.Parameter or None expected)
PuNeal opened this issue · comments
Hello, I met a issue as described in title, the complete error message is:
Traceback (most recent call last):
File "tasks/prune_helmet.py", line 154, in
solver.run()
File "/home/bengui/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torchpruner-0.0.1-py3.7.egg/torchslim/slim_solver.py", line 345, in run
File "/home/bengui/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torchpruner-0.0.1-py3.7.egg/torchslim/slim_solver.py", line 220, in run_hook
File "/home/bengui/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torchpruner-0.0.1-py3.7.egg/torchslim/pruning/resrep.py", line 304, in after_iteration_hook
File "/home/bengui/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torchpruner-0.0.1-py3.7.egg/torchslim/pruning/resrep.py", line 195, in prune_model
File "/home/bengui/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torchpruner-0.0.1-py3.7.egg/torchpruner/model_pruner.py", line 71, in set_cut
File "/home/bengui/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torchpruner-0.0.1-py3.7.egg/torchpruner/module_pruner/pruners.py", line 109, in set_cut
File "/home/bengui/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/nn/modules/module.py", line 801, in setattr
.format(torch.typename(value), name))
TypeError: cannot assign 'torch.cuda.FloatTensor' as parameter 'weight' (torch.nn.Parameter or None expected)
Can you help me fix this bug? The version of torch is 1.7.0, and cuda is 10.2. Thx!
Show me the source code, I will check where the error is.
I've merged #6, so you may run git pull
on your local repo and reinstall it.
I've merged #6, so you may run
git pull
on your local repo and reinstall it.
Thanks for your in-time reply. I tried to pull the latest code and retrain, but got such error message:
Traceback (most recent call last):
File "tasks/prune_helmet.py", line 158, in
solver.run()
File "/home/bengui/miniconda3/envs/torch1.7/lib/python3.6/site-packages/torchpruner-0.0.1-py3.6.egg/torchslim/slim_solver.py", line 327, in run
File "/home/bengui/miniconda3/envs/torch1.7/lib/python3.6/site-packages/torch/optim/lr_scheduler.py", line 67, in wrapper
return wrapped(*args, **kwargs)
File "/home/bengui/miniconda3/envs/torch1.7/lib/python3.6/site-packages/torch/autograd/grad_mode.py", line 26, in decorate_context
return func(*args, **kwargs)
File "/home/bengui/miniconda3/envs/torch1.7/lib/python3.6/site-packages/torch/optim/sgd.py", line 106, in step
buf.mul_(momentum).add_(d_p, alpha=1 - dampening)
RuntimeError: The size of tensor a (96) must match the size of tensor b (88) at non-singleton dimension 0
pull the latest code, and try it again. The error has been fixed.
pull the latest code, and try it again. The error has been fixed.
I tried it again and the error had been fixed.