gpt4 book ai didi

python - pyopencl 示例设备错误

转载 作者:太空宇宙 更新时间:2023-11-04 01:13:13 28 4
gpt4 key购买 nike


在运行程序时..错误是

Choose platform:
[0] <pyopencl.Platform 'Experimental OpenCL 2.0 CPU Only Platform' at 0x3c14d8>
[1] <pyopencl.Platform 'Intel(R) OpenCL' at 0x3faa30>
Choice [0]:1

设置环境变量

PYOPENCL_CTX='1' to avoid being asked again.
Traceback (most recent call last):
File "C:/Python34/gpu1.py", line 10, in <module>
ctx = cl.create_some_context()
File "C:\Python34\lib\site-packages\pyopencl\__init__.py", line 891, in create_some_context
return Context(devices)
pyopencl.RuntimeError: Context failed: device not available

最佳答案

很可能您的平台/设备之一可以创建上下文。

代替 ctx = cl.create_some_context(),我建议您通过选择您要使用的平台和设备来明确地创建您的上下文。像这样:

platform = cl.get_platforms()[0]    # Select the first platform [0]
device = platform.get_devices()[0] # Select the first device on this platform [0]
context = cl.Context([device]) # Create a context with your device

如果第一个设备/平台 [0] 不工作 - 然后尝试第二个 [1]。尝试所有设备/平台组合,直到其中一个起作用。

如果您想查看您拥有的平台/设备,请运行 this script .

关于python - pyopencl 示例设备错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26395146/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com