From 4ec8e33a6a7a628844fcb9f281a33561d2272f58 Mon Sep 17 00:00:00 2001 From: David Rowenhorst Date: Fri, 26 Jul 2024 17:36:50 -0400 Subject: [PATCH] Attempting to fix issue with Ubuntu, ray, and opencl. Signed-off by: David Rowenhorst --- pyebsdindex/__init__.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/pyebsdindex/__init__.py b/pyebsdindex/__init__.py index b8a23bf..91a2e95 100644 --- a/pyebsdindex/__init__.py +++ b/pyebsdindex/__init__.py @@ -11,17 +11,24 @@ # Try to import only once - also will perform check that at least one GPU is found. +_pyopencl_installed = False try: - _pyopencl_installed = False - import pyopencl - from pyebsdindex.opencl import openclparam - testcl = openclparam.OpenClParam() - try: - gpu = testcl.get_gpu() - if len(gpu) > 0: - _pyopencl_installed = True - except: - raise ImportError('pyopencl could not find GPU') + import pyopencl as cl + plt = cl.get_platforms() + if len(plt) > 0: + for p in plt: + g = p.get_devices(device_type=cl.device_type.GPU) + if len(g) > 0: + _pyopencl_installed = True + break + #from pyebsdindex.opencl import openclparam + #testcl = openclparam.OpenClParam() + #try: + # gpu = testcl.get_gpu() + # if len(gpu) > 0: + # _pyopencl_installed = True + #except: + # raise ImportError('pyopencl could not find GPU') except ImportError: _pyopencl_installed = False