{"action":"created","issue":{"url":"https://api.github.com/repos/silx-kit/silx/issues/473","repository_url":"https://api.github.com/repos/silx-kit/silx","labels_url":"https://api.github.com/repos/silx-kit/silx/issues/473/labels{/name}","comments_url":"https://api.github.com/repos/silx-kit/silx/issues/473/comments","events_url":"https://api.github.com/repos/silx-kit/silx/issues/473/events","html_url":"https://github.com/silx-kit/silx/issues/473","id":195902886,"number":473,"title":"silx is unable to find device (either CPU or GPU)","user":{"login":"dgtlmoon","id":275001,"avatar_url":"https://avatars.githubusercontent.com/u/275001?v=3","gravatar_id":"","url":"https://api.github.com/users/dgtlmoon","html_url":"https://github.com/dgtlmoon","followers_url":"https://api.github.com/users/dgtlmoon/followers","following_url":"https://api.github.com/users/dgtlmoon/following{/other_user}","gists_url":"https://api.github.com/users/dgtlmoon/gists{/gist_id}","starred_url":"https://api.github.com/users/dgtlmoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgtlmoon/subscriptions","organizations_url":"https://api.github.com/users/dgtlmoon/orgs","repos_url":"https://api.github.com/users/dgtlmoon/repos","events_url":"https://api.github.com/users/dgtlmoon/events{/privacy}","received_events_url":"https://api.github.com/users/dgtlmoon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-15T20:05:33Z","updated_at":"2016-12-18T14:25:28Z","closed_at":null,"body":"Approximately following http://www.silx.org/doc/silx/dev/Tutorials/Sift/sift.html , I get this error that I'm unable to work around\r\n\r\n\r\nSome simple python code based on http://www.silx.org/doc/silx/dev/Tutorials/Sift/sift.html\r\n\r\n```\r\nimport scipy.misc\r\nimport os\r\nfrom silx.image import sift\r\nfrom pylab import *\r\nimport numpy\r\nfrom numpy import median\r\nimport pyopencl\r\n\r\nimage = scipy.misc.ascent()\r\nimshow(image, cmap=\"gray\")\r\nos.environ[\"PYOPENCL_COMPILER_OUTPUT\"] = \"1\" #set to 1 to see the compilation going on\r\nsift_ocl = sift.SiftPlan(template=image, devicetype=\"GPU\") #switch to GPU to test your graphics card\r\nkeypoints = sift_ocl(image)\r\n# Shift new image\r\nshifted = numpy.zeros_like(image)\r\nshifted[5:,8:] = image[:-5, :-8]\r\nshifted_points = sift_ocl(shifted)\r\n# Match\r\nmp = sift.MatchPlan()\r\nmatch = mp(keypoints, shifted_points)\r\n```\r\n\r\nThe error when `devicetype=\"GPU\"`\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"./sift.py\", line 31, in <module>\r\n    mp = sift.MatchPlan()\r\n  File \"/usr/local/lib/python2.7/dist-packages/silx/image/sift/match.py\", line 107, in __init__\r\n    self.ctx = pyopencl.Context(devices=[pyopencl.get_platforms()[self.device[0]].get_devices()[self.device[1]]])\r\nTypeError: 'NoneType' object has no attribute '__getitem__'\r\n\r\n```\r\n\r\nThe error when `devicetype=\"CPU\"`\r\n\r\n```\r\nWARNING:sift.plan:Unable to find suitable device, selecting device: 0,0\r\nTraceback (most recent call last):\r\n  File \"./sift.py\", line 19, in <module>\r\n    mp = sift.MatchPlan()\r\n  File \"/usr/local/lib/python2.7/dist-packages/silx/image/sift/match.py\", line 107, in __init__\r\n    self.ctx = pyopencl.Context(devices=[pyopencl.get_platforms()[self.device[0]].get_devices()[self.device[1]]])\r\nTypeError: 'NoneType' object has no attribute '__getitem__'\r\n```\r\n\r\nPoking about with `pyopencl` I can see things work\r\n\r\n```\r\n>>> import pyopencl\r\n>>> \r\n>>> pyopencl.get_platforms()\r\n[<pyopencl.Platform 'NVIDIA CUDA' at 0x2b496b0>]\r\n>>> \r\n>>> \r\n>>> pyopencl.get_platforms()[0].get_devices()\r\n[<pyopencl.Device 'GeForce GTX 960M' on 'NVIDIA CUDA' at 0x2b40e90>]\r\n```\r\n\r\nRunning `pyopencl (2016.2)` and `silx (0.3.0)`,  CPU is `Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz` on Ubuntu 16.04\r\n\r\n`nvidia-smi` tells me all is fine also\r\n\r\n```\r\n$ nvidia-smi\r\nThu Dec 15 21:05:11 2016       \r\n+-----------------------------------------------------------------------------+\r\n| NVIDIA-SMI 367.57                 Driver Version: 367.57                    |\r\n|-------------------------------+----------------------+----------------------+\r\n| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |\r\n| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |\r\n|===============================+======================+======================|\r\n|   0  GeForce GTX 960M    Off  | 0000:01:00.0     Off |                  N/A |\r\n| N/A   51C    P0    N/A /  N/A |    807MiB /  2002MiB |     12%      Default |\r\n+-------------------------------+----------------------+----------------------+\r\n                                                                               \r\n+-----------------------------------------------------------------------------+\r\n| Processes:                                                       GPU Memory |\r\n|  GPU       PID  Type  Process name                               Usage      |\r\n|=============================================================================|\r\n|    0      1798    G   /usr/lib/xorg/Xorg                             580MiB |\r\n|    0      5453    G   ...gn/Enabled/GoogleBrandedContextMenu/brand   226MiB |\r\n+-----------------------------------------------------------------------------+\r\n```\r\n\r\nI should add that I see the same error when i run https://github.com/silx-kit/silx/blob/master/silx/image/sift/match.py\r\n\r\n```\r\nWARNING:sift.plan:Unable to find suitable device, selecting device: 0,0\r\nTraceback (most recent call last):\r\n  File \"./match.py\", line 350, in <module>\r\n    demo()\r\n  File \"./match.py\", line 343, in demo\r\n    mp = MatchPlan()\r\n  File \"./match.py\", line 107, in __init__\r\n    self.ctx = pyopencl.Context(devices=[pyopencl.get_platforms()[self.device[0]].get_devices()[self.device[1]]])\r\nTypeError: 'NoneType' object has no attribute '__getitem__'\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/silx-kit/silx/issues/comments/267824081","html_url":"https://github.com/silx-kit/silx/issues/473#issuecomment-267824081","issue_url":"https://api.github.com/repos/silx-kit/silx/issues/473","id":267824081,"user":{"login":"dgtlmoon","id":275001,"avatar_url":"https://avatars.githubusercontent.com/u/275001?v=3","gravatar_id":"","url":"https://api.github.com/users/dgtlmoon","html_url":"https://github.com/dgtlmoon","followers_url":"https://api.github.com/users/dgtlmoon/followers","following_url":"https://api.github.com/users/dgtlmoon/following{/other_user}","gists_url":"https://api.github.com/users/dgtlmoon/gists{/gist_id}","starred_url":"https://api.github.com/users/dgtlmoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgtlmoon/subscriptions","organizations_url":"https://api.github.com/users/dgtlmoon/orgs","repos_url":"https://api.github.com/users/dgtlmoon/repos","events_url":"https://api.github.com/users/dgtlmoon/events{/privacy}","received_events_url":"https://api.github.com/users/dgtlmoon/received_events","type":"User","site_admin":false},"created_at":"2016-12-18T14:25:28Z","updated_at":"2016-12-18T14:25:28Z","body":"Heya, thanks for the reply.\r\n\r\nyeah so...\r\n\r\n\r\n```\r\n>>> import pyopencl\r\n>>> pyopencl.create_some_context()\r\nChoose platform:\r\n[0] <pyopencl.Platform 'NVIDIA CUDA' at 0x2e13660>\r\nChoice [0]:0\r\nSet the environment variable PYOPENCL_CTX='0' to avoid being asked again.\r\n<pyopencl.Context at 0x2c72da0 on <pyopencl.Device 'GeForce GTX 960M' on 'NVIDIA CUDA' at 0x2e0ae40>>\r\n\r\n```\r\n\r\nunsure, like I shown above `nvidia-smi` says everything is functioning"}}
{"actor":{"display_login":"dgtlmoon"}}