{"action":"created","issue":{"url":"https://api.github.com/repos/pfnet/chainer/issues/339","labels_url":"https://api.github.com/repos/pfnet/chainer/issues/339/labels{/name}","comments_url":"https://api.github.com/repos/pfnet/chainer/issues/339/comments","events_url":"https://api.github.com/repos/pfnet/chainer/issues/339/events","html_url":"https://github.com/pfnet/chainer/issues/339","id":102413935,"number":339,"title":"cupy.cudnn.reset_handles() fails for atexit run time","user":{"login":"kikusu","id":7224921,"avatar_url":"https://avatars.githubusercontent.com/u/7224921?v=3","gravatar_id":"","url":"https://api.github.com/users/kikusu","html_url":"https://github.com/kikusu","followers_url":"https://api.github.com/users/kikusu/followers","following_url":"https://api.github.com/users/kikusu/following{/other_user}","gists_url":"https://api.github.com/users/kikusu/gists{/gist_id}","starred_url":"https://api.github.com/users/kikusu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kikusu/subscriptions","organizations_url":"https://api.github.com/users/kikusu/orgs","repos_url":"https://api.github.com/users/kikusu/repos","events_url":"https://api.github.com/users/kikusu/events{/privacy}","received_events_url":"https://api.github.com/users/kikusu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-21T16:20:11Z","updated_at":"2015-08-25T05:02:40Z","closed_at":null,"body":"- chainer (fc79c3caf0a5ebea1bcbb1570b48c057577cf1ad) with GPU\r\n- cuDNN not installed\r\n- python (using pyenv)\r\n\r\n```\r\nPython 2.7.10 (default, Jun 19 2015, 20:41:53)\r\n[GCC 4.8.4] on linux2\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> import chainer\r\n>>> exit()\r\nError in atexit._run_exitfuncs:\r\nTraceback (most recent call last):\r\n  File \"****/2.7.10/lib/python2.7/atexit.py\", line 24, in _run_exitfuncs\r\n    func(*targs, **kargs)\r\n  File \"cupy/cudnn.py\", line 35, in reset_handles\r\n    for handle in six.itervalues(handles):\r\nAttributeError: 'NoneType' object has no attribute 'itervalues'\r\nError in sys.exitfunc:\r\nTraceback (most recent call last):\r\n  File \"***/2.7.10/lib/python2.7/atexit.py\", line 24, in _run_exitfuncs\r\n    func(*targs, **kargs)\r\n  File \"cupy/cudnn.py\", line 35, in reset_handles\r\n    for handle in six.itervalues(handles):\r\nAttributeError: 'NoneType' object has no attribute 'itervalues'\r\n```\r\n\r\nI can see the problem as follows\r\n1. cupy/cudnn.py:10 `from cupy.cuda import cudnn` fails because cuDNN is not installed.\r\n2. However, `import cupy.cudnn` fails because `cudnn` is used in cupy/cudnn.py (name 'cudnn' is not defined)\r\n3. The handling of the global variable(`cupy.cudnn._handles`) of this time seems to be different from python3.3~ in python2.\r\n\r\ntest_code.py\r\n```\r\nimport atexit\r\n\r\nglobal_variable = []\r\n\r\n@atexit.register\r\ndef exit_func():\r\n    global global_variable\r\n    print(\"global_variable is \", global_variable)\r\n\r\n\r\nfail_code # this is fail code\r\n```\r\n\r\npython 2.7.10\r\n```\r\nPython 2.7.10 (default, Jun 19 2015, 20:41:53)\r\n[GCC 4.8.4] on linux2\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> import test_code\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"test_code.py\", line 11, in <module>\r\n    fail_code # this is fail code\r\nNameError: name 'fail_code' is not defined\r\n>>> exit()\r\n('global_variable is ', None)\r\n```\r\n\r\npython 3.4.3\r\n```\r\nPython 3.4.3 (default, Aug 13 2015, 16:03:08)\r\n[GCC 4.8.4] on linux\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> import test_code\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"test_code.py\", line 11, in <module>\r\n    fail_code # this is fail code\r\nNameError: name 'fail_code' is not defined\r\n>>> exit()\r\nglobal_variable is  []\r\n```\r\nThe result is `[]` in the python3.3.x~, but becomes `None` in python2.\r\nBut python3.0.1, 3.1.5, 3.2.6 result is 'None', python 2.7.0 is [].\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/pfnet/chainer/issues/comments/134474767","html_url":"https://github.com/pfnet/chainer/issues/339#issuecomment-134474767","issue_url":"https://api.github.com/repos/pfnet/chainer/issues/339","id":134474767,"user":{"login":"beam2d","id":392019,"avatar_url":"https://avatars.githubusercontent.com/u/392019?v=3","gravatar_id":"","url":"https://api.github.com/users/beam2d","html_url":"https://github.com/beam2d","followers_url":"https://api.github.com/users/beam2d/followers","following_url":"https://api.github.com/users/beam2d/following{/other_user}","gists_url":"https://api.github.com/users/beam2d/gists{/gist_id}","starred_url":"https://api.github.com/users/beam2d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beam2d/subscriptions","organizations_url":"https://api.github.com/users/beam2d/orgs","repos_url":"https://api.github.com/users/beam2d/repos","events_url":"https://api.github.com/users/beam2d/events{/privacy}","received_events_url":"https://api.github.com/users/beam2d/received_events","type":"User","site_admin":false},"created_at":"2015-08-25T05:02:40Z","updated_at":"2015-08-25T05:02:40Z","body":"Thank you for the detailed report! I notice that I mistook to handle the availability of cuDNN. `cupy.cudnn` should not be importable if cuDNN is not available. I'll fix it."}}