I want to create a context for a specific device on my platform. But I get an error message.
the code:
import pyopencl as cl
platform = cl.get_platforms()
devices = platform[0].get_devices(cl.device_type.GPU)
ctx = cl.Context(devices[0])
The error I get is:
Traceback (most recent call last):
File "D:\Programming\Programs_OpenCL_Python\Matrix Multiplication\3\main3.py", line 16, in <module>
ctx = cl.Context(devices[0])
AttributeError: 'Device' object has no attribute '__iter__'
The program compiles and runs without errors and warnings if I use:
ctx = cl.create_some_context()
But I will have to manually select the type of device every time I run the program using this function. I can set the following environment variable
PYOPENCL_CTX='0'
Using this, I will not be able to create contexts for the different devices available based on this requirement. By default, it will be installed on device 0 for all contexts that I create.
Can someone please help me with this problem.
thank
source
share