Search code examples
linuxanacondaopenclnvidiapyopencl

OpenCL doesn't display Nvidia GPU


Hopefully this isn't a duplicate, I did have a look around but correct me if I'm wrong.

I recently installed pyopencl via Anaconda and it runs on my Intel CPU without a problem. However, when I call:

for platform in get_platforms():
    print(platform.name)

ctx = create_some_context()

for dev in ctx.devices:
    print(dev.name)

All I get back is:

Portable Computing Language
Choose platform:
[0] <pyopencl.Platform 'Portable Computing Language' at 0x7f0ff2205020>
>> 0
Choice [0]:0
Set the environment variable PYOPENCL_CTX='0' to avoid being asked again.
pthread-Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz

I have the Nvidia GeForce GTX 1050 Ti, and the driver version is 390.87 with CUDA 9.1, which should be compatible according to the Nvidia release notes. I'm also running Linux Mint 19.1 (if that's relevant), and am also a bit of a noob when it comes to this stuff as my background is in Physics, not computer science.

I read somewhere (I can't remember where) that I should have an nvidia.icd file but all that's present is a pocl.icd file in /home//anaconda3/etc/OpenCL/vendors and I'm not sure how/where to get an nvidia.icd file.

Thanks in advance for any help, and let me know if you need anymore info!

Edit: added the result of get_platforms()

Edit 2: I was able to find an nvidia.icd file in my /etc/OpenCL/vendors directory. I copied this over to the Anaconda directory, /home/<user>/anaconda3/etc/OpenCL/vendors and pyopencl now recognises Nvidia CUDA as a platform, and my GPU as a device.

Unfortunately it's still loading the tasks off to the CPU, but there's a good chance that's because of my code and I haven't properly figured out how to create context on the GPU yet.


Solution

  • This question is a bit stale, but I ran across it while trying to solve exactly this problem, I had a freshly-installed PyOpenCL package inside a Conda environment on Ubuntu Linux, and it was not listing my GPU in the list of platforms and their associated devices.

    The 2nd edit by the OP, where he copied over the nvidia.icd file from /etc/OpenCL/vendors worked for me, but it didn't feel right, so I dug a bit deeper into the PyOpenCL documentation, which recommends, in addition to the PyOpenCL package, doing conda install ocl-icd-system. (See the section on "Using vendor-supplied drivers" on that page.)

    This works, and gets you all of the system capabilities -- I think it's a cleaner approach than copying .icd files around.