diff --git a/pystencils/datahandling/pycuda.py b/pystencils/datahandling/pycuda.py index 75967c1cc25591ba9c4b0b127519205eb2af7208..14e255c8520d72e42ccc281fa522df8e9e37020e 100644 --- a/pystencils/datahandling/pycuda.py +++ b/pystencils/datahandling/pycuda.py @@ -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!") diff --git a/pystencils/datahandling/serial_datahandling.py b/pystencils/datahandling/serial_datahandling.py index e5244c05a166306347a9b5e948145305f9a870bc..7352951d22393d58ca6f6bef52522e5760ba71cb 100644 --- a/pystencils/datahandling/serial_datahandling.py +++ b/pystencils/datahandling/serial_datahandling.py @@ -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): try: 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)