ERROR: pyopencl: creating context for specific device

前端 未结 1 771
面向向阳花
面向向阳花 2021-01-01 07:47

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         


        
相关标签:
1条回答
  • 2021-01-01 08:43

    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]]
    
    0 讨论(0)
提交回复
热议问题