diff --git a/pyclesperanto/__init__.py b/pyclesperanto/__init__.py index 50913e87..b667ec4d 100644 --- a/pyclesperanto/__init__.py +++ b/pyclesperanto/__init__.py @@ -27,4 +27,6 @@ from ._interroperability import * # isort:skip +print(f"pyclesperanto version: {__version__}") + default_initialisation() diff --git a/pyclesperanto/_core.py b/pyclesperanto/_core.py index f5112099..71512556 100644 --- a/pyclesperanto/_core.py +++ b/pyclesperanto/_core.py @@ -43,6 +43,7 @@ def select_device(device_id: Union[str, int] = "", device_type: str = "all") -> ------- device : Device """ + print("\t\tselecting device ...") if isinstance(device_id, str): device = BackendManager.get_backend().getDeviceFromName(device_id, device_type) elif isinstance(device_id, int): @@ -54,6 +55,7 @@ def select_device(device_id: Union[str, int] = "", device_type: str = "all") -> if _current_device._instance and device == _current_device._instance: return _current_device._instance _current_device._instance = device + print("\t\tdone!") return device @@ -92,12 +94,14 @@ def list_available_backends() -> list: ------- name list : list[str] """ + print("\tlist available backends ...") back_list = list(BackendManager.get_backends_list()) if not back_list: warnings.warn( "No backend available. Please install either OpenCL or CUDA on your system.", RuntimeWarning, ) + print("\tdone!") return back_list @@ -112,7 +116,7 @@ def select_backend(backend: str = "opencl") -> str: type : str, default = "opencl" determine the backend to use between opencl and cuda """ - + print("\tset backend ...") # enforce lowercase for backend_type backend = backend.lower() # is backend_type is different than "cuda" or "opencl", raise an error @@ -121,8 +125,11 @@ def select_backend(backend: str = "opencl") -> str: f"'{backend}' is not a supported Backend. Please use either 'opencl' or 'cuda'." ) BackendManager.set_backend(backend=backend) + print("\tdone!") # reset current device to default one + print("\tset default device ...") select_device() + print("\tdone!") return f"{BackendManager.get_backend()} selected." @@ -148,12 +155,15 @@ def wait_for_kernel_to_finish(wait: bool = True, device: Device = None): def default_initialisation(): """Set default backend and device""" + try: + print("Initialising pyclesperanto...") backends = list_available_backends() if backends: _ = select_backend(backends[-1]) else: raise RuntimeError("No backend available.") + print("done!") except Exception as e: warnings.warn( f"Error while initialising pyclesperanto: {e}\n\n"