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

AttributeError: 'Monitor' object has no attribute 'set_iter' #12

Open
nhy17-thu opened this issue Mar 21, 2021 · 9 comments
Open

AttributeError: 'Monitor' object has no attribute 'set_iter' #12

nhy17-thu opened this issue Mar 21, 2021 · 9 comments

Comments

@nhy17-thu
Copy link

Hi @justanhduc, when I was running test code with your latest version of neuralnet-pytorch, an error occurred as below:

Traceback (most recent call last):
File "test.py", line 68, in
test_each_category()
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/gin/config.py", line 1069, in gin_wrapper
utils.augment_exception_message_and_reraise(e, err_str)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/gin/utils.py", line 41, in augment_exception_message_and_reraise
raise proxy.with_traceback(exception.traceback) from None
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/gin/config.py", line 1046, in gin_wrapper
return fn(*new_args, **new_kwargs)
File "test.py", line 46, in test_each_category
mon.set_iter(0)
AttributeError: 'Monitor' object has no attribute 'set_iter'
In call to configurable 'GraphX' (<function test_each_category at 0x7f63f181b0d0>)

It seems to be caused by breaking changes in the updated neuralnet-pytorch. Do you know if there are any available fixes to this problem? I could try rolling back the version of neuralnet-pytorch, but I'm afraid that there could be unfixed bugs in the previous versions. Thanks!

@nhy17-thu
Copy link
Author

Update: I've tried roll back neuralnet-pytorch's version to 1c78fe366a6af605385d58dd460ebbb96c1e71f6 as mentioned in previous issues, but the same error still appears and stopped me from testing.

@nhy17-thu
Copy link
Author

nhy17-thu commented Mar 22, 2021

Similarly, when I commented out this line, another similar error occurred:

File "test.py", line 47, in test_each_category
mon.clear_scalar_stats(file_cat + '/test chamfer')
AttributeError: 'Monitor' object has no attribute 'clear_scalar_stats'
In call to configurable 'GraphX' (<function test_each_category at 0x7f05a642a430>)

Can I also comment out this line?

@justanhduc
Copy link
Owner

justanhduc commented Mar 23, 2021

Hi @nhy17-thu .
Please change line 45 to

mon.iter = 0

and line 46 to

mon.clear_num_stats(file_cat + '/test chamfer')

@nhy17-thu
Copy link
Author

Hi @nhy17-thu .
Please change line 45 to

mon.iter = 0

and line 46 to

mon.clear_num_stats(file_cat + '/test chamfer')

Thanks for your advice! Now I can successfully start the testing process, but another exception occurred as follows:

2021-03-23 17:19:27,279 [MainThread ] [WARNI] enter is deprecated and will be removed in version 1.2.0. Use iter_batch instead.
NoneType: None
Exception in thread Thread-1:
Traceback (most recent call last):
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/neuralnet_pytorch/monitor.py", line 1427, in _flush
self._plot(nums, prints)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/neuralnet_pytorch/monitor.py", line 1288, in plot
fig.savefig(os.path.join(self.plot_folder, name.replace(' ', '
') + '.jpg'))
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/figure.py", line 2959, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/backend_bases.py", line 2255, in print_figure
result = print_method(
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/backend_bases.py", line 1669, in wrapper
return func(*args, **kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/_api/deprecation.py", line 431, in wrapper
return func(*inner_args, **inner_kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/_api/deprecation.py", line 431, in wrapper
return func(*inner_args, **inner_kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/_api/deprecation.py", line 431, in wrapper
return func(*inner_args, **inner_kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/backends/backend_agg.py", line 584, in print_jpg
return (Image.fromarray(np.asarray(self.buffer_rgba())[..., :3])
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/PIL/Image.py", line 2161, in save
fp = builtins.open(filename, "w+b")
FileNotFoundError: [Errno 2] No such file or directory: '.../graphx-conv/src/results/ICCV-lowrankgraphx-conv-up-final/run-1/plots/02691156/test-chamfer.jpg'

I've looked for the picture 02691156/test-chamfer.jpg but it didn't exist after the training finished. Anyway, this error does not prevent the program from keeping running, so I wonder if this will interfere with the generation of test results? Now the testing program has been running and printing:

[MainThread ] [WARNI] __enter__ is deprecated and will be removed in version 1.2.0. Use iter_batch instead.

for nearly 3 hours on my RTX3080 and it seems won't stop. Do you have any idea whether these two phenomenons are normal?

@justanhduc
Copy link
Owner

You can change this line to

for itt, batch in mon.iter_batch(enumerate(test_loader)):

and delete this line.
02691156/test-chamfer.jpg is the test error for class 02691156. It appears only after the testing finishes. The testing usually takes a long time. You can check your GPU status to see whether the program is still running or not.

@nhy17-thu
Copy link
Author

You can change this line to

for itt, batch in mon.iter_batch(enumerate(test_loader)):

and delete this line.
02691156/test-chamfer.jpg is the test error for class 02691156. It appears only after the testing finishes. The testing usually takes a long time. You can check your GPU status to see whether the program is still running or not.

Thanks for your reply! Now I can successfully finish the testing process, while there is still no error image generated after that. And I noticed a similar error was generated at the beginning of the testing process:

Exception in thread Thread-1:
Traceback (most recent call last):
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/neuralnet_pytorch/monitor.py", line 1427, in _flush
self._plot(nums, prints)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/neuralnet_pytorch/monitor.py", line 1288, in plot
fig.savefig(os.path.join(self.plot_folder, name.replace(' ', '
') + '.jpg'))
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/figure.py", line 2959, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/backend_bases.py", line 2255, in print_figure
result = print_method(
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/backend_bases.py", line 1669, in wrapper
return func(*args, **kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/_api/deprecation.py", line 431, in wrapper
return func(*inner_args, **inner_kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/_api/deprecation.py", line 431, in wrapper
return func(*inner_args, **inner_kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/_api/deprecation.py", line 431, in wrapper
return func(*inner_args, **inner_kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/backends/backend_agg.py", line 584, in print_jpg
return (Image.fromarray(np.asarray(self.buffer_rgba())[..., :3])
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/PIL/Image.py", line 2161, in save
fp = builtins.open(filename, "w+b")
FileNotFoundError: [Errno 2] No such file or directory: '.../graphx-conv/src/results/ICCV-lowrankgraphx-conv-up-final/run-1/plots/02691156/test-chamfer.jpg'

This exception only appears once at the beginning, and the testing program won't stop even after printing Testing finished.

Could you please inspect and modify the testing code to make it work and generate expected results (e.g. error diagrams)? This should be my last problem because I cannot see any of the results right now even after testing finished. Thanks!

@justanhduc
Copy link
Owner

justanhduc commented Mar 29, 2021

Hi @nhy17-thu. Could you please try using absolute link in the config file? It should be something like /<root>/graphx-conv/src/results/ICCV-lowrankgraphx-conv-up-final/run-1.

@nhy17-thu
Copy link
Author

Hi @nhy17-thu. Could you please try using absolute link in the config file? It should be something like /<root>/graphx-conv/src/results/ICCV-lowrankgraphx-conv-up-final/run-1.

Hi, I indeed was using the absolute link in the config file. Below is the full error:

Traceback (most recent call last):
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/neuralnet_pytorch/monitor.py", line 1427, in _flush
self._plot(nums, prints)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/neuralnet_pytorch/monitor.py", line 1288, in plot
fig.savefig(os.path.join(self.plot_folder, name.replace(' ', '
') + '.jpg'))
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/figure.py", line 2959, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/backend_bases.py", line 2255, in print_figure
result = print_method(
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/backend_bases.py", line 1669, in wrapper
return func(*args, **kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/_api/deprecation.py", line 431, in wrapper
return func(*inner_args, **inner_kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/_api/deprecation.py", line 431, in wrapper
return func(*inner_args, **inner_kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/_api/deprecation.py", line 431, in wrapper
return func(*inner_args, **inner_kwargs)
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/matplotlib-3.4.0rc3-py3.8-linux-x86_64.egg/matplotlib/backends/backend_agg.py", line 584, in print_jpg
return (Image.fromarray(np.asarray(self.buffer_rgba())[..., :3])
File "/home/niuhaoyu/anaconda3/envs/graphX-cuda/lib/python3.8/site-packages/PIL/Image.py", line 2161, in save
fp = builtins.open(filename, "w+b")
FileNotFoundError: [Errno 2] No such file or directory: '/mnt/c/graphx-conv/src/results/ICCV-lowrankgraphx-conv-up-final/run-1/plots/02691156/test-chamfer.jpg'

@justanhduc
Copy link
Owner

Hi @nhy17-thu. Please replace mon.current_folder by mon.plot_folder in here and here. It should work now but feel free to let me know if otherwise.

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