0

I am struggling with the following Python code:

import pyopencl as cl
ctx = cl.Context(dev_type=cl.device_type.GPU)

It gives the following exception:

RuntimeError: clcreatecontextfromtype failed: DEVICE_NOT_FOUND

My OS is Linux Mint Debian Edition 2, running on a laptop with i7-5600U. It also has a graphic card, but I do not use it. I am using Python 3.4.2.

I have installed the Debian package amd-opencl-icd (I first tried beignet, but then the command clinfo failed).

I have installed pyopencl using pip and opencl using this tutorial. Note that I did not do the fourth step (creating the symbolic link to intel64.icd), since I did not have this file. The test at the end of the tutorial succeed.

Do you have any hint about what is happening? I am surprised that the C++ test of opencl (in the tutorial) and the installation of pyopencl both succeed, but this simple command of pyopencl fails.


EDIT After installing the Intel driver, I now have a different issue.

The command clinfo gives the following:

terminate called after throwing an instance of 'unsigned long'

And the above Python code gives:

LogicError: clcreatecontextfromtype failed: INVALID_PLATFORM
asked Feb 11, 2016 at 8:01

1 Answer 1

1

You've installed the intel opencl SDK, which gives you the compiler and maybe the CPU runtime. You're trying to create a context consisting of GPU devices, which means that you need the runtime for intel HD graphics. Grab the 64-bit driver from the link below.

https://software.intel.com/en-us/articles/opencl-drivers#latest_linux_driver

The CPU runtime is also available from that link. You need to follow the same procedure as before for the opencl HD graphics driver (converting .rpm to .deb). The CPU driver has a script you can execute.

The INVALID_PLATFORM error you got after installing the runtime appears to be because it expects the platform to be passed as a property, when creating from device type. It expects the properties as a list of key-tuple pairs. This is shown in the snippet below for the first available platform. The keyword is one of the values in context_properties, and the value is the platform object itself.

import pyopencl as cl
platforms = cl.get_platforms()
ctx = cl.Context(dev_type=cl.device_type.GPU, properties=[(cl.context_properties.PLATFORM, platforms[0])])
print(ctx.devices)

On my platform this prints

[<pyopencl.Device 'Intel(R) HD Graphics 4600' on 'Intel(R) OpenCL' at 0x1c04b217140>]

as my first platform is intel.

answered Feb 11, 2016 at 19:31
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your answer. I now have a different issue, I updated my question.
Updated my answer to solve your issues when creating a context from device type. The documentation is not very clear on this. The error message could also be improved

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.