Irina Fateeva
Irina Fateeva

Reputation: 81

Python LogicError: clGetPlatformIDs failed: platform not found khr

While making nosetests for the set of Python programs in Ubuntu an error occurs:

devices = [ d for d in cl.get_platforms()[0].get_devices() if
LogicError: clGetPlatformIDs failed: platform not found khr


File "/home/fateeva/prog/deflectometry/SGMFMeasurement/_PhaseShifts.py", line 30, in <module>
    devices = [ d for d in cl.get_platforms()[0].get_devices() if
LogicError: clGetPlatformIDs failed: platform not found khr

How it's possible to fix it?

Upvotes: 8

Views: 19528

Answers (7)

Azzam Radman
Azzam Radman

Reputation: 53

Updated:

pip install pocl-binary-distribution

might work. It worked for me.

Upvotes: 1

Chien Nguyen
Chien Nguyen

Reputation: 179

Try

$ sudo apt install pocl-opencl-icd

I tested it on Ubuntu WSL for Windows 10, Python 3.8.10.

Upvotes: 5

John Rambo
John Rambo

Reputation: 156

this is a bug. Try this:

sudo apt-get install nvidia-settings
sudo nvidia-smi

or run it (without sudo) as root.

After that your should be able to run it.

Add

nvidia-smi

to /etc/rc.local (before exit, of course), so you GPU will be available after each boot.

Upvotes: 1

Serhii Yaskovets
Serhii Yaskovets

Reputation: 51

It seems you have pyopencl installed but none of the actual device drivers. Please consult the documentation at https://documen.tician.de/pyopencl/misc.html.

Here is the description of such a behaviour:

Note that PyOpenCL is no fun (i.e. cannot run code) without an OpenCL device driver (a so-called “ICD”, for “installable client driver”) that provides access to hardware through OpenCL. If you get an error message like pyopencl.cffi_cl.LogicError: clGetPlatformIDs failed: , that means you have no OpenCL drivers installed.

Basically, the next command should be enough to get it running on a CPU:

[pip]conda install pocl

For proper installation of AMD and Nvidia devices look for vendor supplied OpenCL drivers.

Upvotes: 5

Anonymous Platypus
Anonymous Platypus

Reputation: 1302

This could be because OpenCL drivers arent properly installed.

Intel CPUs require OpenCL Runtime for Intel Core and Intel Xeon Processors (16.1.1 or later). Download and install OpenCL™ Runtime latest from intel website. Ignore the compatibility warning.

Source: https://youtu.be/AieYqNQ6ADM

Upvotes: 1

pram
pram

Reputation: 1513

Try running your python script as root. If cl.get_platforms() does not throw any errors under root, then your user does not have sufficient privilege to perform the action. To solve this, install nvidia-modprobe package:

sudo apt-get install nvidia-modprobe

Source

Upvotes: 0

Yash
Yash

Reputation: 699

Try this. It should work:

devices = [ d for d in cl.get_platforms()[0].get_devices(cl.device_type.GPU)]

If you want to list all the compatible devices on your platform just use

platform = cl.get_platform()
my_devices = platform[0].get_devices(device_type = cl.devices_type.ALL)
print my_devices

To create a context on any compatible device use this:

context = cl.Context([my_devices[<index>])

Where corresponds to the device for which you want to create a context. for example:

context = cl.Context([my_devices[0])

also refer to this post of mine, it will help. I too had problems with this:

pyopencl: creating context for specific device

Upvotes: -1

Related Questions