Commit f5d3f8d9 authored by Stephan Seitz's avatar Stephan Seitz
Browse files

Throw an error when performing GPU operations with SerialDataHandling when pycuda is not available

parent b44b0045
Pipeline #25148 passed with stage
in 11 minutes and 32 seconds
......@@ -39,3 +39,9 @@ class PyCudaArrayHandler:
return self.to_gpu(cpu_array)
from_numpy = to_gpu
class PyCudaNotAvailableHandler:
def __getattribute__(self, name):
raise NotImplementedError("Unable to initiaize PyCuda! "
"Try to run `import pycuda.autoinit` to check whether PyCuda is working correctly!")
......@@ -6,7 +6,7 @@ import numpy as np
from pystencils.datahandling.blockiteration import SerialBlock
from pystencils.datahandling.datahandling_interface import DataHandling
from pystencils.datahandling.pycuda import PyCudaArrayHandler
from pystencils.datahandling.pycuda import PyCudaArrayHandler, PyCudaNotAvailableHandler
from pystencils.datahandling.pyopencl import PyOpenClArrayHandler
from pystencils.field import (
Field, FieldType, create_numpy_array_with_layout, layout_string_to_tuple,
......@@ -53,7 +53,7 @@ class SerialDataHandling(DataHandling):
self.array_handler = PyCudaArrayHandler()
except Exception:
self.array_handler = None
self.array_handler = PyCudaNotAvailableHandler()
if default_target == 'opencl' or opencl_queue:
self.array_handler = PyOpenClArrayHandler(opencl_queue)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment