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

TypeError: 'NoneType' object is not callable #1289

Open
uduse opened this issue Feb 5, 2022 · 7 comments
Open

TypeError: 'NoneType' object is not callable #1289

uduse opened this issue Feb 5, 2022 · 7 comments
Labels
area / SDK-storage Issue area: SDK and storage related issues help wanted Extra attention is needed phase / exploring Issue phase: issue is in discovery phase type / bug Issue type: something isn't working

Comments

@uduse
Copy link
Contributor

uduse commented Feb 5, 2022

🐛 Bug

(compiler_gym) zeyi@server121:~/scripts$ python main.py 
Exception in thread Thread-1:
Traceback (most recent call last):
  File ".../lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File ".../lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File ".../lib/python3.8/site-packages/aim/ext/resource/tracker.py", line 102, in _stat_collector
    self._track(stat)
  File ".../lib/python3.8/site-packages/aim/ext/resource/tracker.py", line 78, in _track
    self._track_func()(
TypeError: 'NoneType' object is not callable

To reproduce

Minimum example:

from aim import Run


def main():
    run = Run()
    for i in range(1000):
        run.track(i, name="loss")


if __name__ == "__main__":
    main()

This problem happens occasionally. In my case it happens one out of four times. However, if I change the script slightly, the problem above never appears.

from aim import Run

run = Run()

def main():
    for i in range(1000):
        run.track(i, name="loss")


if __name__ == "__main__":
    main()

Notice that I moved the variable run into global scope. I think the problem is due to some objects are de-referenced too quickly (e.g., the thread used to track? I'm not sure).

Expected behavior

The script should run without problem.

Environment

aim==3.4.1
aimrecords==0.0.7
aimrocks==0.0.10

Python 3.8.12

Linux server121 5.4.0-26-generic #30-Ubuntu SMP Mon Apr 20 16:58:30 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
@uduse uduse added help wanted Extra attention is needed type / bug Issue type: something isn't working labels Feb 5, 2022
@alberttorosyan alberttorosyan added phase / exploring Issue phase: issue is in discovery phase area / SDK-storage Issue area: SDK and storage related issues labels Feb 5, 2022
@gorarakelyan gorarakelyan moved this to [current] Sprint Q1-6: 7-13 Feb '22 in Aim roadmap Feb 7, 2022
@alberttorosyan
Copy link
Member

Hi @uduse!
I was not able to reproduce this behavior with aim v3.5.1. We made several bug fixes and improvements in this version and it may be fixed indirectly.
May I ask you to switch to the latest version and check if it solves the issue on your side?

@alberttorosyan
Copy link
Member

Hey @uduse. Just wanted to check, did you have a chance to try (and possibly reproduce this issue) with aim v3.5.1+?
Thanks in advance.

@gorarakelyan gorarakelyan moved this from [done] Sprint Q1-6: 7-13 Feb '22 to [current] Sprint Q1-7: 14-20 Feb '22 in Aim roadmap Feb 14, 2022
@uduse
Copy link
Contributor Author

uduse commented Feb 14, 2022

@alberttorosyan Yeah I can't reproduce this problem with the new version of aim 👍 nice fix

@uduse uduse closed this as completed Feb 14, 2022
@uduse
Copy link
Contributor Author

uduse commented Mar 15, 2022

I'm experiencing the same problem again. Though I can't reproduce the same problem in the small demo I shown above, this happens in my complicated project and I don't know what's going on...

Exception in thread Thread-34:
Traceback (most recent call last):
  File "/home/zeyi/anaconda3/envs/compiler_gym/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/home/zeyi/anaconda3/envs/compiler_gym/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/zeyi/anaconda3/envs/compiler_gym/lib/python3.8/site-packages/aim/ext/resource/tracker.py", line 104, in _stat_collector
    self._track(stat)
  File "/home/zeyi/anaconda3/envs/compiler_gym/lib/python3.8/site-packages/aim/ext/resource/tracker.py", line 88, in _track
    self._track_func()(
TypeError: 'NoneType' object is not callable

@uduse uduse reopened this Mar 15, 2022
@alberttorosyan
Copy link
Member

@uduse let me share a bit of what's going on under the hood here. it might give you some ideas wrt how the more complex scenario might affect things.
so the resource tracking (when it's enabled) collects system resource usage info and tracks it as a regular metrics on the Run object. this is done in a separate thread, which is shut down when the Run is finished. it seems that the Run object is closed for writes before system tracking thread is shut down. is it possible that the Run.close/finalize methods are called explicitly?

@uduse
Copy link
Contributor Author

uduse commented Mar 15, 2022

No I don't call those functions explicitly. Could it be a concurrency problem? I'm having multiple async functions and each one of them has their own aim.Run object.

@gorarakelyan gorarakelyan moved this from [done] Sprint Q1-7: 14-20 Feb '22 to Backlog in Aim roadmap Mar 18, 2022
@sbuschjaeger
Copy link

I ran into this a few days ago with aim 3.19.3 and it was somewhat difficult to track down when using more than 1 thread for data loading.
Weirdly enough, it only occurred when using a smaller development data set (and not the entire dataset) and only after a sufficiently long runtime (e.g. when running 5 experiments, the first two finish and the third one randomly hangs).

Exception ignored in: <finalize object at 0x7f34d1c1ce60; dead>
Traceback (most recent call last):
  File "/usr/lib/python3.10/weakref.py", line 591, in __call__
    return info.func(*info.args, **(info.kwargs or {}))
  File ".venv/sw/lib/python3.10/site-packages/aim/sdk/run.py", line 107, in _close
    res.close()
  File ".venv/sw/lib/python3.10/site-packages/aim/ext/resource/tracker.py", line 143, in close
    self.stop()
  File ".venv/sw/lib/python3.10/site-packages/aim/ext/resource/tracker.py", line 131, in stop
    self._th_collector.join()
  File "/usr/lib/python3.10/threading.py", line 1093, in join
    raise RuntimeError("cannot join current thread")
RuntimeError: cannot join current thread
2024-07-23 10:17:00,571 | INFO | BaseClassifier.py:182 | Star working on batch 0 for TEST
2024-07-23 10:17:00,576 | INFO | BaseClassifier.py:201 | Forward on batch 0 for TEST
Exception in thread Thread-721 (_stat_collector):
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File ".venv/sw/lib/python3.10/site-packages/aim/ext/resource/tracker.py", line 189, in _stat_collector
    self._store_buffered_logs()
  File ".venv/sw/lib/python3.10/site-packages/aim/ext/resource/tracker.py", line 226, in _store_buffered_logs
    self._tracker()(LogLine(line.decode()), name='logs', step=self._line_counter)
TypeError: 'NoneType' object is not callable

I will update aim (although the changelog does not suggest any changes that might be relevant) and disable resource tracking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area / SDK-storage Issue area: SDK and storage related issues help wanted Extra attention is needed phase / exploring Issue phase: issue is in discovery phase type / bug Issue type: something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

3 participants