microsoft / nni

An open source AutoML toolkit for automate machine learning lifecycle, including feature engineering, neural architecture search, model compression and hyper-parameter tuning.
https://nni.readthedocs.io
MIT License
14.06k stars 1.82k forks source link

RuntimeError: Only tensors, lists, tuples of tensors, or dictionary of tensors can be output from traced functions #5655

Closed RToF closed 1 year ago

RToF commented 1 year ago

when I followed https://nni.readthedocs.io/zh/stable/tutorials/pruning_quick_start_mnist.html , This error occured during running "ModelSpeedup(model, torch.rand(1, 3, 28, 28).to('cuda'), masks).speedup_model()" on my own model.

I try to change the output type but it seems does not matter.

more detailed position and info: .../lib/python3.7/site-packages/torch/jit/_trace.py module._c._create_method_from_trace( method_name, # 'forward' func, # My own model' example_inputs, # torch.rand(1, 3, 28, 28).to('cuda') var_lookup_fn, strict, _force_outplace, argument_names, # ['images', 'targets'] ) RuntimeError: Only tensors, lists, tuples of tensors, or dictionary of tensors can be output from traced functions