Skip to content

Commit

Permalink
Merge pull request #293 from clEsperanto/update-clic-0.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
StRigaud authored Nov 21, 2024
2 parents 17b5404 + 649c896 commit 56751c3
Show file tree
Hide file tree
Showing 44 changed files with 4,680 additions and 2,689 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]
platform: [ubuntu-latest, macos-latest] #, windows-latest]
python-version: ["3.9", "3.13"]
platform: [ubuntu-latest, macos-latest]
defaults:
run:
shell: "bash -l {0}"
Expand All @@ -26,6 +26,18 @@ jobs:
id: checkout
uses: actions/checkout@v4

# - name: setup micromamba
# id: setup-micromamba
# uses: mamba-org/[email protected]
# with:
# environment-name: test
# cache-environment: true
# post-cleanup: 'all'
# create-args: >-
# python=${{ matrix.python-version }}
# pytest pytest-cov pytest-benchmark scikit-image


- name: Get conda - ${{ matrix.python-version }}
id: get-conda
uses: conda-incubator/setup-miniconda@v3
Expand Down Expand Up @@ -55,7 +67,7 @@ jobs:
- name: Build
id: build
run: |
pip install . -vvv --config-settings=cmake.define.CMAKE_PREFIX_PATH=$CONDA_PREFIX
pip install . -v --config-settings=cmake.define.CMAKE_PREFIX_PATH=$CONDA_PREFIX
- name: Test
id: test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: actions/checkout@v4

- name: Build wheels
uses: pypa/[email protected]
uses: pypa/cibuildwheel@v2.21.3 #2.19.2
env:
CIBW_ARCHS_MACOS: x86_64 arm64

Expand Down
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ ci:
autoupdate_schedule: monthly
autofix_commit_msg: "style(pre-commit.ci): auto fixes"
autoupdate_commit_msg: "ci(pre-commit.ci): auto update"
autofix_prs: false # tag the PR with 'pre-commit.ci autofix' to run it

default_install_hook_types:
- pre-commit
- commit-msg

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
654 changes: 654 additions & 0 deletions demos/advance/multi-gpu_tile_processing_with_dask.ipynb

Large diffs are not rendered by default.

179 changes: 107 additions & 72 deletions demos/advance/multi_gpu_demo.ipynb

Large diffs are not rendered by default.

File renamed without changes.
436 changes: 436 additions & 0 deletions demos/basics/arithmetic_operators.ipynb

Large diffs are not rendered by default.

71 changes: 38 additions & 33 deletions demos/basics/colors.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demos/basics/count_blobs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
309 changes: 0 additions & 309 deletions demos/basics/crop_and_paste_images.ipynb

This file was deleted.

535 changes: 535 additions & 0 deletions demos/basics/crop_flip_paste.ipynb

Large diffs are not rendered by default.

156 changes: 0 additions & 156 deletions demos/basics/equal_constant.ipynb

This file was deleted.

86 changes: 52 additions & 34 deletions demos/basics/image_size_limitations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
{
"data": {
"text/plain": [
"(OpenCL) NVIDIA GeForce RTX 2080 SUPER (OpenCL 3.0 CUDA)\n",
"\tType: GPU\n",
"\tCompute Units: 48\n",
"\tGlobal Memory Size: 8358 MB\n",
"\tMaximum Object Size: 2089 MB"
"(OpenCL) NVIDIA GeForce RTX 4090 (OpenCL 3.0 CUDA)\n",
"\tVendor: NVIDIA Corporation\n",
"\tDriver Version: 535.216.01\n",
"\tDevice Type: GPU\n",
"\tCompute Units: 128\n",
"\tGlobal Memory Size: 24217 MB\n",
"\tMaximum Object Size: 6054 MB\n",
"\tMax Clock Frequency: 2625 MHz\n",
"\tImage Support: Yes"
]
},
"execution_count": 1,
Expand All @@ -32,8 +36,9 @@
],
"source": [
"import pyclesperanto as cle\n",
"import numpy as np\n",
"\n",
"cle.get_device()"
"cle.select_device()"
]
},
{
Expand Down Expand Up @@ -173,24 +178,14 @@
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"4 warnings generated.\n"
]
},
{
"ename": "RuntimeError",
"evalue": "Error: Fail to launch kernel. OpenCL error : CL_MEM_OBJECT_ALLOCATION_FAILURE (-4).",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[7], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m result \u001b[38;5;241m=\u001b[39m cle\u001b[38;5;241m.\u001b[39mset_ramp_x(image)\n\u001b[1;32m 2\u001b[0m result\u001b[38;5;241m.\u001b[39mshape\n",
"File \u001b[0;32m~/Libraries/miniconda3/envs/build8/lib/python3.11/site-packages/pyclesperanto/_decorators.py:85\u001b[0m, in \u001b[0;36mplugin_function.<locals>.worker_function\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 82\u001b[0m bound\u001b[38;5;241m.\u001b[39marguments[key] \u001b[38;5;241m=\u001b[39m input_image\u001b[38;5;241m.\u001b[39mdevice\n\u001b[1;32m 84\u001b[0m \u001b[38;5;66;03m# call the decorated function\u001b[39;00m\n\u001b[0;32m---> 85\u001b[0m result \u001b[38;5;241m=\u001b[39m function(\u001b[38;5;241m*\u001b[39mbound\u001b[38;5;241m.\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mbound\u001b[38;5;241m.\u001b[39mkwargs)\n\u001b[1;32m 87\u001b[0m \u001b[38;5;66;03m# # Cast the result as an Array if it is not already\u001b[39;00m\n\u001b[1;32m 88\u001b[0m \u001b[38;5;66;03m# if not isinstance(result, _Array):\u001b[39;00m\n\u001b[1;32m 89\u001b[0m \u001b[38;5;66;03m# result = _Array(result)\u001b[39;00m\n\u001b[1;32m 91\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m result\n",
"File \u001b[0;32m~/Libraries/miniconda3/envs/build8/lib/python3.11/site-packages/pyclesperanto/_tier1.py:1272\u001b[0m, in \u001b[0;36mset_ramp_x\u001b[0;34m(input_image, device)\u001b[0m\n\u001b[1;32m 1268\u001b[0m \u001b[38;5;129m@plugin_function\u001b[39m\n\u001b[1;32m 1269\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mset_ramp_x\u001b[39m(input_image: Image, device: Device \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Image:\n\u001b[1;32m 1270\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01m_pyclesperanto\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m _set_ramp_x \u001b[38;5;28;01mas\u001b[39;00m op\n\u001b[0;32m-> 1272\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m op(device\u001b[38;5;241m=\u001b[39mdevice, src\u001b[38;5;241m=\u001b[39minput_image)\n",
"\u001b[0;31mRuntimeError\u001b[0m: Error: Fail to launch kernel. OpenCL error : CL_MEM_OBJECT_ALLOCATION_FAILURE (-4)."
]
"data": {
"text/plain": [
"(1024, 1024, 4096)"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
Expand All @@ -199,23 +194,46 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1024f696",
"cell_type": "markdown",
"id": "e33fae42-cbeb-4380-aafc-a1d9a33ff49c",
"metadata": {},
"outputs": [],
"source": [
"result"
"We have now twice the data size used in our device, for the `image` and the `results`. This saturate our memory and we cannot do much more without releasing some space. For that we can delete the `image` now that it has been process."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fad9c3be",
"execution_count": 8,
"id": "363c331e-4bf2-459a-8fad-0b0b88c7197a",
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "RuntimeError",
"evalue": "Error: Fail to read buffer memory. OpenCL error : CL_OUT_OF_RESOURCES (-5).",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[8], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m res \u001b[38;5;241m=\u001b[39m \u001b[43mcle\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpull\u001b[49m\u001b[43m(\u001b[49m\u001b[43mresult\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m/data/clesperanto/pyclesperanto/pyclesperanto/_memory.py:128\u001b[0m, in \u001b[0;36mpull\u001b[0;34m(array)\u001b[0m\n\u001b[1;32m 115\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Pull the input image from the device to the host.\u001b[39;00m\n\u001b[1;32m 116\u001b[0m \n\u001b[1;32m 117\u001b[0m \u001b[38;5;124;03mParameters\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 125\u001b[0m \u001b[38;5;124;03m Image data\u001b[39;00m\n\u001b[1;32m 126\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 127\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(array, Array):\n\u001b[0;32m--> 128\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43marray\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 129\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m array\n",
"File \u001b[0;32m/data/clesperanto/pyclesperanto/pyclesperanto/_array.py:108\u001b[0m, in \u001b[0;36mget\u001b[0;34m(self, origin, region)\u001b[0m\n\u001b[1;32m 83\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Get the content of the Array into a numpy array.\u001b[39;00m\n\u001b[1;32m 84\u001b[0m \n\u001b[1;32m 85\u001b[0m \u001b[38;5;124;03mParameters\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 95\u001b[0m \u001b[38;5;124;03m The array itself.\u001b[39;00m\n\u001b[1;32m 96\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 97\u001b[0m caster \u001b[38;5;241m=\u001b[39m {\n\u001b[1;32m 98\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mfloat32\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_read_float32,\n\u001b[1;32m 99\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mint8\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_read_int8,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 106\u001b[0m \u001b[38;5;66;03m# \"uint64\": self._read_uint64,\u001b[39;00m\n\u001b[1;32m 107\u001b[0m }\n\u001b[0;32m--> 108\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mcaster\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdtype\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mname\u001b[49m\u001b[43m]\u001b[49m\u001b[43m(\u001b[49m\u001b[43morigin\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mregion\u001b[49m\u001b[43m)\u001b[49m\n",
"\u001b[0;31mRuntimeError\u001b[0m: Error: Fail to read buffer memory. OpenCL error : CL_OUT_OF_RESOURCES (-5)."
]
}
],
"source": [
"print(cle.cl_info())"
"res = cle.pull(result)"
]
},
{
"cell_type": "markdown",
"id": "816dbc04-e048-426c-8077-7555c2691213",
"metadata": {},
"source": [
"If you experiencing this error:\n",
"> RuntimeError: Error: Fail to read buffer memory. OpenCL error : CL_OUT_OF_RESOURCES (-5).\n",
"\n",
"with the following code `CL_OUT_OF_RESOURCES`, it is most likely that you did not have enough memory on your device for the data you are trying to process."
]
},
{
Expand Down Expand Up @@ -243,7 +261,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
84 changes: 0 additions & 84 deletions demos/basics/imshow.ipynb

This file was deleted.

214 changes: 98 additions & 116 deletions demos/basics/inspecting_3d_images.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demos/basics/label_statistics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 56751c3

Please sign in to comment.