I want to create context for specific device on my platform. But I am getting an error.
Code:
import pyopencl as cl
platform = cl.get_platforms()
dev
According to the PyOpenCL documentation, Context takes a list of devices, not a specific device.
If you change your context creation code to this:
platform = cl.get_platforms()
my_gpu_devices = platform[0].get_devices(device_type=cl.device_type.GPU)
ctx = cl.Context(devices=my_gpu_devices)
It should work. If you really want to limit the choice to only one device, you can manipulate the my_gpu_devices
list, for instance:
my_gpu_devices = [platform[0].get_devices(device_type=cl.device_type.GPU)[0]]