{"action":"created","issue":{"url":"https://api.github.com/repos/apache/incubator-mxnet/issues/13695","repository_url":"https://api.github.com/repos/apache/incubator-mxnet","labels_url":"https://api.github.com/repos/apache/incubator-mxnet/issues/13695/labels{/name}","comments_url":"https://api.github.com/repos/apache/incubator-mxnet/issues/13695/comments","events_url":"https://api.github.com/repos/apache/incubator-mxnet/issues/13695/events","html_url":"https://github.com/apache/incubator-mxnet/pull/13695","id":392856312,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQwMDMwNjMw","number":13695,"title":"fix bug in profiler tutorial when using cpu","user":{"login":"Soonhwan-Kwon","id":7395166,"node_id":"MDQ6VXNlcjczOTUxNjY=","avatar_url":"https://avatars1.githubusercontent.com/u/7395166?v=4","gravatar_id":"","url":"https://api.github.com/users/Soonhwan-Kwon","html_url":"https://github.com/Soonhwan-Kwon","followers_url":"https://api.github.com/users/Soonhwan-Kwon/followers","following_url":"https://api.github.com/users/Soonhwan-Kwon/following{/other_user}","gists_url":"https://api.github.com/users/Soonhwan-Kwon/gists{/gist_id}","starred_url":"https://api.github.com/users/Soonhwan-Kwon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Soonhwan-Kwon/subscriptions","organizations_url":"https://api.github.com/users/Soonhwan-Kwon/orgs","repos_url":"https://api.github.com/users/Soonhwan-Kwon/repos","events_url":"https://api.github.com/users/Soonhwan-Kwon/events{/privacy}","received_events_url":"https://api.github.com/users/Soonhwan-Kwon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-12-20T02:05:42Z","updated_at":"2018-12-21T20:58:20Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/apache/incubator-mxnet/pulls/13695","html_url":"https://github.com/apache/incubator-mxnet/pull/13695","diff_url":"https://github.com/apache/incubator-mxnet/pull/13695.diff","patch_url":"https://github.com/apache/incubator-mxnet/pull/13695.patch"},"body":"## Description ##\r\nWhen using cpu only, it produces error because test_utils.list_gpus() always returns at least empty array, and do not goes to the exception and context will be set as gpu. So I used if else statement to get context properly and it works fine.\r\nFor the reference below is the code of test_utils.py\r\n\r\npython/mxnet/test_utils.py\r\n```python\r\ndef list_gpus():\r\n    \"\"\"Return a list of GPUs\r\n    Returns\r\n    -------\r\n    list of int:\r\n        If there are n GPUs, then return a list [0,1,...,n-1]. Otherwise returns\r\n        [].\r\n    \"\"\"\r\n    re = ''\r\n    nvidia_smi = ['nvidia-smi', '/usr/bin/nvidia-smi', '/usr/local/nvidia/bin/nvidia-smi']\r\n    for cmd in nvidia_smi:\r\n        try:\r\n            re = subprocess.check_output([cmd, \"-L\"], universal_newlines=True)\r\n        except (subprocess.CalledProcessError, OSError):\r\n            pass\r\n    return range(len([i for i in re.split('\\n') if 'GPU' in i]))\r\n```\r\n\r\nand Error message\r\nrun_training_iteration(*next(itr))\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"<stdin>\", line 5, in run_training_iteration\r\n  File \"/home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet/ndarray/ndarray.py\", line 2135, in as_in_context\r\n    return self.copyto(context)\r\n  File \"/home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet/ndarray/ndarray.py\", line 2084, in copyto\r\n    return _internal._copyto(self, out=hret)\r\n  File \"<string>\", line 25, in _copyto\r\n  File \"/home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet/_ctypes/ndarray.py\", line 92, in _imperative_invoke\r\n    ctypes.byref(out_stypes)))\r\n  File \"/home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet/base.py\", line 252, in check_call\r\n    raise MXNetError(py_str(_LIB.MXGetLastError()))\r\nmxnet.base.MXNetError: [03:59:09] src/ndarray/ndarray.cc:1270: GPU is not enabled\r\n\r\nStack trace returned 10 entries:\r\n[bt] (0) /home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x21f5a4) [0x7fd2f7def5a4]\r\n[bt] (1) /home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x21f981) [0x7fd2f7def981]\r\n[bt] (2) /home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(mxnet::CopyFromTo(mxnet::NDArray const&, mxnet::NDArray const&, int, bool)+0x723) [0x7fd2fa8bc323]\r\n[bt] (3) /home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(mxnet::imperative::PushFComputeEx(std::function<void (nnvm::NodeAttrs const&, mxnet::OpContext const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> > const&)> const&, nnvm::Op const*, nnvm::NodeAttrs const&, mxnet::Context const&, std::vector<mxnet::engine::Var*, std::allocator<mxnet::engine::Var*> > const&, std::vector<mxnet::engine::Var*, std::allocator<mxnet::engine::Var*> > const&, std::vector<mxnet::Resource, std::allocator<mxnet::Resource> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&)::{lambda(mxnet::RunContext)#1}::operator()(mxnet::RunContext) const+0x110) [0x7fd2fa763ba0]\r\n[bt] (4) /home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(mxnet::imperative::PushFComputeEx(std::function<void (nnvm::NodeAttrs const&, mxnet::OpContext const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> > const&)> const&, nnvm::Op const*, nnvm::NodeAttrs const&, mxnet::Context const&, std::vector<mxnet::engine::Var*, std::allocator<mxnet::engine::Var*> > const&, std::vector<mxnet::engine::Var*, std::allocator<mxnet::engine::Var*> > const&, std::vector<mxnet::Resource, std::allocator<mxnet::Resource> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&)+0x3ca) [0x7fd2fa76ee5a]\r\n[bt] (5) /home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(mxnet::Imperative::InvokeOp(mxnet::Context const&, nnvm::NodeAttrs const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&, mxnet::DispatchMode, mxnet::OpStatePtr)+0x839) [0x7fd2fa7748a9]\r\n[bt] (6) /home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(mxnet::Imperative::Invoke(mxnet::Context const&, nnvm::NodeAttrs const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&)+0x38c) [0x7fd2fa77512c]\r\n[bt] (7) /home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x2ab24f9) [0x7fd2fa6824f9]\r\n[bt] (8) /home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(MXImperativeInvokeEx+0x6f) [0x7fd2fa682aef]\r\n[bt] (9) /home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/lib-dynload/../../libffi.so.6(ffi_call_unix64+0x4c) [0x7fd3097dcec0]\r\n\r\n## Checklist ##\r\n### Essentials ###\r\nPlease feel free to remove inapplicable items for your PR.\r\n- [x] Changes are complete (i.e. I finished coding on this PR)\r\n"},"comment":{"url":"https://api.github.com/repos/apache/incubator-mxnet/issues/comments/449496700","html_url":"https://github.com/apache/incubator-mxnet/pull/13695#issuecomment-449496700","issue_url":"https://api.github.com/repos/apache/incubator-mxnet/issues/13695","id":449496700,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0OTQ5NjcwMA==","user":{"login":"Roshrini","id":8004078,"node_id":"MDQ6VXNlcjgwMDQwNzg=","avatar_url":"https://avatars1.githubusercontent.com/u/8004078?v=4","gravatar_id":"","url":"https://api.github.com/users/Roshrini","html_url":"https://github.com/Roshrini","followers_url":"https://api.github.com/users/Roshrini/followers","following_url":"https://api.github.com/users/Roshrini/following{/other_user}","gists_url":"https://api.github.com/users/Roshrini/gists{/gist_id}","starred_url":"https://api.github.com/users/Roshrini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roshrini/subscriptions","organizations_url":"https://api.github.com/users/Roshrini/orgs","repos_url":"https://api.github.com/users/Roshrini/repos","events_url":"https://api.github.com/users/Roshrini/events{/privacy}","received_events_url":"https://api.github.com/users/Roshrini/received_events","type":"User","site_admin":false},"created_at":"2018-12-21T20:58:20Z","updated_at":"2018-12-21T20:58:20Z","author_association":"CONTRIBUTOR","body":"I am not aware that we are deprecating this method otherwise LGTM. @marcoabreu can you provide details whenever you have time? Thanks!\r\n@mxnet-label-bot Add [pr-awaiting-review]"}}
{"actor":{"display_login":"Roshrini"}}