Core functions

Collection of functions to explore and select system devices (e.g. GPUs) and initialize a device to work with.

default_initialisation()[source]

Set default backend and device

get_device() pyclesperanto._pyclesperanto._Device[source]

Return the current device instance

Returns:

device

Return type:

Device

info()[source]

Print information about the devices available on the system

list_available_backends() list[source]

Retrieve a list of names of available backends

Will test system for available backends installed and return a list of their names.

Returns:

name list

Return type:

list[str]

list_available_devices(device_type: str = 'all') list[source]

Retrieve a list of names of available devices

Will search the system for backend compatible device available and return a list of their names. This will NOT set the device! Use ‘select_device’ to select devices. Use ‘get_device’ to retrieve the current device.

Parameters:

device_type (str, default = "all") – Type of device to be selected (e.g. “all”, “cpu”, “gpu”)

Returns:

name list

Return type:

list[str]

select_backend(backend: str = 'opencl') str[source]

select backend

Select the backend used by pyclesperanto, OpenCL or CUDA. Default is OpenCL.

Parameters:

type (str, default = "opencl") – determine the backend to use between opencl and cuda

select_device(device_id: str | int = '', device_type: str = 'all') pyclesperanto._pyclesperanto._Device[source]

Select a device by ‘name’ or ‘index’ and by ‘type’, and store it as the current device

If selecting the device by string, the function compares the device name and substring. (e.g. “NVIDIA”, “RTX”, “Iris”, etc. will match the device name “NVIDIA RTX 2080” or “Intel Iris Pro”) If selecting the device by index, the function will select the device at the given index in the list of available devices. (e.g. 0, 1, 2, etc. will select the first, second, third, etc. device in the list) If device_id is an empty string, the function will select the first available device. The device_type enables selecting the type of device to be selected (e.g. “all”, “cpu”, “gpu”) To retrieve a list of available devices, use list_available_devices()

Parameters:
  • device_id (Union[str, int], default = "") – Substring of device name or device index.

  • device_type (str, default = "all") – Type of device to be selected (e.g. “all”, “cpu”, “gpu”)

Returns:

device

Return type:

Device

wait_for_kernel_to_finish(wait: bool = True, device: pyclesperanto._pyclesperanto._Device = None)[source]

Wait for kernel to finish

Enforce the system to wait for the kernel to finish before continuing. Introducing a slowdown in the workflow. This is useful for debugging purposes, benchmarking and profiling, as well as for complex workflows where the order of operations is important.

Parameters:
  • wait (bool, default = True) – if True, wait for kernel to finish

  • device (Device, default = None) – the device to set the flag. If None, set it to the current device