prav
prav

Reputation: 205

pyopencl example device error


while running program..error is

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

Set the environment variable

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

Upvotes: 2

Views: 2951

Answers (1)

benshope
benshope

Reputation: 3024

It is likely one of your platforms/devices will work to make a context.

Instead of ctx = cl.create_some_context(), I recommend you make your context explicitly - by selecting which platform and which device you want to use. Like this:

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

If the first device/platform [0] doesn't work - then try the second one [1]. Try all devices/platform combinations until one of them works.

If you want to see what platforms/devices you have, run this script.

Upvotes: 4

Related Questions