Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5269cea
Update pyclesperanto to 0.23.0
github-actions[bot] Jun 16, 2026
d0904b0
style(pre-commit.ci): auto fixes
pre-commit-ci[bot] Jun 16, 2026
c64aee8
bumpt version
Jun 16, 2026
ef10308
Update pyclesperanto to 0.23.0
github-actions[bot] Jun 16, 2026
2dd6dab
Update pyclesperanto to 0.23.0
github-actions[bot] Jun 16, 2026
3b68796
Update pyclesperanto to 0.23.0
github-actions[bot] Jun 16, 2026
45badf9
Update pyclesperanto to 0.23.0
github-actions[bot] Jun 16, 2026
8a66b97
Update pyclesperanto to 0.23.0
github-actions[bot] Jun 16, 2026
887ce3a
Update pyclesperanto to 0.23.0
github-actions[bot] Jun 16, 2026
d746454
bump trigget
Jun 16, 2026
fb64def
style(pre-commit.ci): auto fixes
pre-commit-ci[bot] Jun 16, 2026
43ad95c
fix codecov version
Jun 17, 2026
e496c95
Update pyclesperanto to 0.23.0
github-actions[bot] Jun 17, 2026
0eec699
Update pyclesperanto to 0.23.0
github-actions[bot] Jun 17, 2026
e3b92d5
add deprecated `create_labels_like` #398
Jun 17, 2026
1c58d13
style(pre-commit.ci): auto fixes
pre-commit-ci[bot] Jun 17, 2026
b5fa9d6
fix kernel path management #399
Jun 17, 2026
6567229
update tests
Jun 17, 2026
5cfb071
add support for numpy c type #401
Jun 17, 2026
63d3ccb
style(pre-commit.ci): auto fixes
pre-commit-ci[bot] Jun 17, 2026
06c7a4d
use custom deprecated instead of the PEP702
Jun 17, 2026
a78b07b
style(pre-commit.ci): auto fixes
pre-commit-ci[bot] Jun 17, 2026
2786bf3
do not skip cuda build
Jun 17, 2026
9f37816
bump to Beta
Jun 17, 2026
de9c2c0
Update pyclesperanto to 0.23.0
github-actions[bot] Jun 19, 2026
2a0275a
fix translation typo
Jun 19, 2026
7395dae
add test data
Jun 19, 2026
7b8032c
add illustration
Jun 19, 2026
c4df98e
fix another typo
Jun 19, 2026
0cdb03a
update example
Jun 19, 2026
74ceccf
style(pre-commit.ci): auto fixes
pre-commit-ci[bot] Jun 19, 2026
9aad555
clean up init and deprecation msg
Jun 23, 2026
0b72e52
style(pre-commit.ci): auto fixes
pre-commit-ci[bot] Jun 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:

- name: Upload coverage
if: matrix.backend == 'OPENCL' && github.actor != 'dependabot[bot]'
uses: codecov/codecov-action@v6.0.0
uses: codecov/codecov-action@v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/coverage.xml
Expand Down
17 changes: 3 additions & 14 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,16 @@ jobs:
build_cuda_wheels:
name: build cuda (${{ matrix.os }})
runs-on: ${{ matrix.os }}
if: github.event_name == 'release' || contains(github.event.pull_request.labels.*.name, 'ready-to-deploy')
# if: github.event_name == 'release' || contains(github.event.pull_request.labels.*.name, 'ready-to-deploy')
strategy:
fail-fast: false
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]

steps:
- name: Checkout
uses: actions/checkout@v6

# - name: Install CUDA Toolkit (Windows)
# if: matrix.os == 'windows-latest'
# uses: Jimver/cuda-toolkit@v0.2.35
# with:
# cuda: '12.6.0'
# method: 'local'
# sub-packages: '["nvcc","cudart","cudart-dev","nvrtc","nvrtc-dev"]'
# non-cuda-sub-packages: '["nvJitLink","nvJitLink-dev"]'
# use-local-cache: true
# use-github-cache: false

- name: Install CUDA Toolkit (Windows)
if: matrix.os == 'windows-latest'
id: cuda-toolkit-windows
Expand Down Expand Up @@ -95,7 +84,7 @@ jobs:
runs-on: ${{ matrix.os }}
# if: github.event_name == 'release' || contains(github.event.pull_request.labels.*.name, 'ready-to-deploy')
strategy:
fail-fast: false
fail-fast: true
matrix:
os: [macos-latest]

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ __pycache__/

# IDE
.vscode
.abacusai

# pixi
.pixi/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Image.sc Forum](https://img.shields.io/badge/dynamic/json.svg?label=forum&url=https%3A%2F%2Fforum.image.sc%2Ftags%2Fpyclesperanto.json&query=%24.topic_list.tags.0.topic_count&colorB=green&&suffix=%20topics&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAABPklEQVR42m3SyyqFURTA8Y2BER0TDyExZ+aSPIKUlPIITFzKeQWXwhBlQrmFgUzMMFLKZeguBu5y+//17dP3nc5vuPdee6299gohUYYaDGOyyACq4JmQVoFujOMR77hNfOAGM+hBOQqB9TjHD36xhAa04RCuuXeKOvwHVWIKL9jCK2bRiV284QgL8MwEjAneeo9VNOEaBhzALGtoRy02cIcWhE34jj5YxgW+E5Z4iTPkMYpPLCNY3hdOYEfNbKYdmNngZ1jyEzw7h7AIb3fRTQ95OAZ6yQpGYHMMtOTgouktYwxuXsHgWLLl+4x++Kx1FJrjLTagA77bTPvYgw1rRqY56e+w7GNYsqX6JfPwi7aR+Y5SA+BXtKIRfkfJAYgj14tpOF6+I46c4/cAM3UhM3JxyKsxiOIhH0IO6SH/A1Kb1WBeUjbkAAAAAElFTkSuQmCC)](https://forum.image.sc/tag/pyclesperanto)
[![PyPI](https://img.shields.io/pypi/v/pyclesperanto.svg?color=green)](https://pypi.org/project/pyclesperanto)
[![License](https://img.shields.io/pypi/l/pyclesperanto.svg?color=green)](https://github.com/clEsperanto/pyclesperanto/blob/main/LICENSE)
[![Development Status](https://img.shields.io/pypi/status/pyclesperanto.svg)](https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha)
[![Development Status](https://img.shields.io/pypi/status/pyclesperanto.svg)](https://en.wikipedia.org/wiki/Software_release_life_cycle#Beta)
[![Build](https://github.com/clEsperanto/pyclesperanto/actions/workflows/build.yml/badge.svg)](https://github.com/clEsperanto/pyclesperanto/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/clesperanto/pyclesperanto/branch/main/graph/badge.svg)](https://codecov.io/gh/clesperanto/pyclesperanto)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.13853800.svg)](https://doi.org/10.5281/zenodo.13853800)
Expand Down
232 changes: 232 additions & 0 deletions docs/demos/api/manage_backends.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "fa467b9c",
"metadata": {},
"source": [
"# Backends\n",
"\n",
"Depending on your system and your `pyclesperanto` installation, various backend will be available.\n",
"\n",
"The backends are the low-level language used to access and run processing kernel on your Computational Units (GPU, CPU, etc.).\n",
"By default, `pyclesperanto` comes with `OpenCL` which is a widely compatible backend that runs on most system. It is also possible to use `CUDA` or `Metal` if you have installed it and is compatible with your system.\n",
"See the [pyclesperanto installation instructions](https://clesperanto-doc.readthedocs.io/en/latest/docs/pyclesperanto/install.html) for more details.\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "69c32066",
"metadata": {},
"outputs": [],
"source": [
"import pyclesperanto as cle"
]
},
{
"cell_type": "markdown",
"id": "52f3036a-a773-46df-987f-7a68c2a9cac2",
"metadata": {},
"source": [
"Importing the package will automatically load the first available backend and device it can find.\n",
"If no backend were found, or that the backend that was loaded does not find any compatible devices, the package will raise an error.\n",
"\n",
"Otherwise, we can check which backend is used.\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "1922cc9a-556c-414e-ade1-be8c517c209b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'opencl'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cle.get_backend_name()"
]
},
{
"cell_type": "markdown",
"id": "761621a8-a5c3-4a79-b61c-8edee79714a9",
"metadata": {},
"source": [
"We are not surprised to have `OpenCL` here, it is the default backend and the most compatible with all systems.\n",
"Bet let see if we have other backend available."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "dc4eaf76-f528-4256-a611-02ea3053bb73",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['opencl', 'metal']"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cle.list_available_backends()"
]
},
{
"cell_type": "markdown",
"id": "fbb5a94f",
"metadata": {},
"source": [
"We have an other backend available, `Metal`, which is available only for MacOS system. Let's select it."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "94bcd15a-7e60-47f8-a54a-de61bd2dac95",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 - (Metal) Apple M5 Max\n",
"\tVendor: Apple\n",
"\tDevice Type: gpu\n",
"\tLocal Memory Size: 32 KB\n",
"\tMaximum Buffer Size: 39813 MB\n",
"\tHas Unified Memory: Yes\n",
"\tImage Support: No\n",
"\n"
]
}
],
"source": [
"cle.select_backend(\"Metal\")\n",
"cle.info()"
]
},
{
"cell_type": "markdown",
"id": "f862b9d5-2243-49ba-b49f-e5d7835392d6",
"metadata": {},
"source": [
"We sucessfully switch to metal, and when requesting information on the system we find the Apple Processing Unit. \n",
"We can of course return to `OpenCL` if prefered."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "6f7f61c0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 - (OpenCL) Apple M5 Max (OpenCL 1.2)\n",
"\tVendor: Apple\n",
"\tDriver Version: 1.2 1.0\n",
"\tDevice Type: GPU\n",
"\tCompute Units: 40\n",
"\tGlobal Memory Size: 53084 MB\n",
"\tLocal Memory Size: 0 MB\n",
"\tMaximum Buffer Size: 9953 MB\n",
"\tMax Clock Frequency: 1000 MHz\n",
"\tImage Support: Yes\n",
"\n"
]
}
],
"source": [
"cle.select_backend(\"opencl\")\n",
"cle.info()"
]
},
{
"cell_type": "markdown",
"id": "4c751a14",
"metadata": {},
"source": [
"We can see here that `OpenCL` can manage Apple devices due to its wide compatiblity.\n",
"It is interesting to see that `cle.info()`, depending on the backend, does not provide the same informations. This comes from the differences between the language.\n",
"Native backends, here `Metal`, should be more accurate.\n",
"\n",
"Now, if we try to select a backend that is not available."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "b4562e0b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Error occurred: 'cuda' backend is not installed. Install with: pip install pyclesperanto[cuda]\n",
"\tCUDA backend is not available. Please ensure that you have the necessary CUDA drivers installed and that your GPU supports CUDA.\n",
"\tReverting to: opencl.\n"
]
}
],
"source": [
"try:\n",
" cle.select_backend(\"cuda\")\n",
"except Exception as e:\n",
" print(f\"Error occurred: {e}\")\n",
" print(\"\\tCUDA backend is not available. Please ensure that you have the necessary CUDA drivers installed and that your GPU supports CUDA.\")\n",
" print(f\"\\tReverting to: {cle.get_backend_name()}.\")"
]
},
{
"cell_type": "markdown",
"id": "d872eb11",
"metadata": {},
"source": [
"The error was expected, so we can managed it to select an other backend.\n",
"\n",
"**WARNING:** Being at the based of all device selection, memory management, and processing, the backend should be defined at the **start** of the processes and **should not be modified** afterward until the end of the processing!"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "pyclesperanto:default (3.13.12)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Loading