-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #303 from clEsperanto/test
Test inf-sup with morphological snakes
- Loading branch information
Showing
118 changed files
with
11,748 additions
and
892 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,262 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "e535dc08-1602-4ad0-9b79-db9a8a4b607f", | ||
"metadata": {}, | ||
"source": [ | ||
"# Pyclesperanto on Apple M1 CPUs/GPUs\n", | ||
"This notebook serves exploring and basic benchmarking of CPUs and GPUs in an Apple M1 laptop" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "4bb88b1a-2e9a-463f-9b3f-095d7766e9b8", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"['Apple M1 Max', 'Apple M1 Max']" | ||
] | ||
}, | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"import numpy as np\n", | ||
"import napari_segment_blobs_and_things_with_membranes as nsbatwm\n", | ||
"import timeit\n", | ||
"import pyclesperanto_prototype as cle\n", | ||
"cle.available_device_names()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "105c5a7f-6b94-44bc-a4a5-b1bbbfa6577a", | ||
"metadata": {}, | ||
"source": [ | ||
"## Defining test data\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "d96117ce-5312-477d-a646-04db49204dce", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"image = np.random.random((2048, 2048))\n", | ||
"\n", | ||
"sigma_spot_detection = 1\n", | ||
"sigma_outline = 1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "c64a6c88-5eaa-43e6-95e0-d7170c6ae9a8", | ||
"metadata": {}, | ||
"source": [ | ||
"## M1 CPU" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "4f9a4565-fe00-4f52-a7d6-92e6592ca11c", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"<Apple M1 Max on Platform: Apple (2 refs)>" | ||
] | ||
}, | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"device = cle.select_device(dev_type='cpu')\n", | ||
"device" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "527744b1-a87a-41c6-9fec-876cf373f6c2", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"2" | ||
] | ||
}, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"device.device.type" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "9dedb68c-4894-41ca-9aca-e62c45fae3ca", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"614 ms ± 6.92 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"%timeit nsbatwm.voronoi_otsu_labeling(image, spot_sigma=sigma_spot_detection, outline_sigma=sigma_outline)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "3e082fb5-b05d-4c43-9df2-148b4dd856f7", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"530 ms ± 5.04 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"%timeit cle.voronoi_otsu_labeling(image, spot_sigma=sigma_spot_detection, outline_sigma=sigma_outline)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "fc839892-799a-478a-8630-e08799abb7dd", | ||
"metadata": {}, | ||
"source": [ | ||
"## M1 GPU" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"id": "596a9fd6-6c16-4ac1-baf2-c1632927281a", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"<Apple M1 Max on Platform: Apple (2 refs)>" | ||
] | ||
}, | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"device = cle.select_device(dev_type='gpu')\n", | ||
"device" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"id": "9b6c2628-a583-43c2-8efb-0ff258f88e45", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"4" | ||
] | ||
}, | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"device.device.type" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"id": "be410bc8-2e74-4a15-9ce9-60c80e3caf4c", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"609 ms ± 3.63 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"%timeit nsbatwm.voronoi_otsu_labeling(image, spot_sigma=sigma_spot_detection, outline_sigma=sigma_outline)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"id": "6d655aed-44f2-42c4-ae10-fb22f8c31232", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"609 ms ± 4.32 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"%timeit nsbatwm.voronoi_otsu_labeling(image, spot_sigma=sigma_spot_detection, outline_sigma=sigma_outline)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "aa036230-428c-495c-a933-0beaf600915c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"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.9.0" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.