Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This error occurred when I calculated flops. What is the reason? #125

Open
fxooooooooo opened this issue Dec 11, 2022 · 1 comment
Open

Comments

@fxooooooooo
Copy link

[12/11 22:09:15 adet.trainer]: Starting training from iteration 0
Traceback (most recent call last):
File "C:\Users\lin\Desktop\Cross_custom_dataset\tools\train_net.py", line 235, in
args=(args, ),
File "C:\Users\lin\Desktop\Cross_custom_dataset\detectron2\detectron2\engine\launch.py", line 82, in launch
main_func(*args)
File "C:\Users\lin\Desktop\Cross_custom_dataset\tools\train_net.py", line 223, in main
return trainer.train()
File "C:\Users\lin\Desktop\Cross_custom_dataset\tools\train_net.py", line 97, in train
self.train_loop(self.start_iter, self.max_iter)
File "C:\Users\lin\Desktop\Cross_custom_dataset\tools\train_net.py", line 87, in train_loop
self.run_step()
File "C:\Users\lin\Desktop\Cross_custom_dataset\detectron2\detectron2\engine\defaults.py", line 495, in run_step
self._trainer.run_step()
File "C:\Users\lin\Desktop\Cross_custom_dataset\detectron2\detectron2\engine\train_loop.py", line 274, in run_step
loss_dict = self.model(data)
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "C:\Users\lin\Desktop\Cross_custom_dataset\adet\modeling\condinst\crossvis.py", line 140, in forward
return self.forward_train(batched_inputs)
File "C:\Users\lin\Desktop\Cross_custom_dataset\adet\modeling\condinst\crossvis.py", line 148, in forward_train
print("FLOPs: ", flops.total())
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\fvcore\nn\jit_analysis.py", line 248, in total
stats = self._analyze()
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\fvcore\nn\jit_analysis.py", line 551, in _analyze
graph = _get_scoped_trace_graph(self._model, self._inputs, self._aliases)
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\fvcore\nn\jit_analysis.py", line 176, in _get_scoped_trace_graph
graph, _ = _get_trace_graph(module, inputs)
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\torch\jit_trace.py", line 1139, in _get_trace_graph
outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\torch\jit_trace.py", line 130, in forward
self._force_outplace,
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\torch\jit_trace.py", line 116, in wrapper
outs.append(self.inner(*trace_inputs))
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\torch\nn\modules\module.py", line 887, in _call_impl
result = self._slow_forward(*input, **kwargs)
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\torch\nn\modules\module.py", line 860, in _slow_forward
result = self.forward(*input, **kwargs)
File "C:\Users\lin\Desktop\Cross_custom_dataset\adet\modeling\condinst\crossvis.py", line 140, in forward
return self.forward_train(batched_inputs)
File "C:\Users\lin\Desktop\Cross_custom_dataset\adet\modeling\condinst\crossvis.py", line 148, in forward_train
print("FLOPs: ", flops.total())
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\fvcore\nn\jit_analysis.py", line 248, in total
stats = self._analyze()
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\fvcore\nn\jit_analysis.py", line 551, in _analyze
graph = _get_scoped_trace_graph(self._model, self._inputs, self._aliases)
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\fvcore\nn\jit_analysis.py", line 176, in _get_scoped_trace_graph
graph, _ = _get_trace_graph(module, inputs)
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\torch\jit_trace.py", line 1139, in _get_trace_graph
outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\torch\nn\modules\module.py", line 887, in _call_impl
result = self._slow_forward(*input, **kwargs)
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\torch\nn\modules\module.py", line 860, in _slow_forward
result = self.forward(*input, **kwargs)
File "C:\Users\lin\anaconda3\envs\cross\lib\site-packages\torch\jit_trace.py", line 130, in forward
self._force_outplace,
RuntimeError: Tracing can't be nested

@ppwwyyxx
Copy link
Contributor

ppwwyyxx commented Feb 2, 2023

FlopCounter cannot be used to count self inside a module. It has to be used outside the module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants