clEsperanto / pyclesperanto_prototype

GPU-accelerated bio-image analysis focusing on 3D+t microscopy image data
http://clesperanto.net
BSD 3-Clause "New" or "Revised" License
208 stars 44 forks source link

Ambiguous call to the convert_uint_sat function #322

Open Robin1em opened 10 months ago

Robin1em commented 10 months ago

When I try applying the Gauss-Otsu-labeling in the following code, I get an error message that the call to the function 'convert_uint_sat' is ambiguous.

from skimage.io import imread
import pyclesperanto_prototype as cle

# load image
input_image = imread("...path/IXMtest_A02_s9.tif")[:,:,0]

# apply Gauss-Otsu-labeling
segmented = cle.gauss_otsu_labeling(input_image, outline_sigma=1)

I use a MacBook Pro with a HD Graphics 4000, OpenCL C version 1.2 and PyOpenCL version 2023.1.4

haesleinhuepf commented 10 months ago

get an error message that the call to the function 'convert_uint_sat' is ambiguous.

Can you copy&paste the error message here so that we can read it? Thanks!

Robin1em commented 10 months ago

Thank you for the quick response! Here's the error message:

File "/Users/Robin/PycharmProjects/imageanalysis_tutorial/1-Image_Segmentation/1.6-Gauss-Otsu-labeling.py", line 9, in segmented = cle.gauss_otsu_labeling(input_image, outline_sigma=1) File "/Users/Robin/PycharmProjects/imageanalysis_tutorial/venv/lib/python3.10/site-packages/pyclesperanto_prototype/_tier0/_plugin_function.py", line 71, in worker_function return function(*bound.args, bound.kwargs) File "/Users/Robin/PycharmProjects/imageanalysis_tutorial/venv/lib/python3.10/site-packages/pyclesperanto_prototype/_tier9/_gauss_otsu_labeling.py", line 45, in gauss_otsu_labeling segmentation = threshold_otsu(temp) File "/Users/Robin/PycharmProjects/imageanalysis_tutorial/venv/lib/python3.10/site-packages/pyclesperanto_prototype/_tier0/_plugin_function.py", line 71, in worker_function return function(*bound.args, *bound.kwargs) File "/Users/Robin/PycharmProjects/imageanalysis_tutorial/venv/lib/python3.10/site-packages/pyclesperanto_prototype/_tier9/_threshold_otsu.py", line 46, in threshold_otsu hist = pull(histogram(source, num_bins=256, minimum_intensity=minimum_intensity, maximum_intensity=maximum_intensity, determine_min_max=False)) File "/Users/Robin/PycharmProjects/imageanalysis_tutorial/venv/lib/python3.10/site-packages/pyclesperanto_prototype/_tier0/_plugin_function.py", line 71, in worker_function return function(bound.args, bound.kwargs) File "/Users/Robin/PycharmProjects/imageanalysis_tutorial/venv/lib/python3.10/site-packages/pyclesperanto_prototype/_tier3/_histogram.py", line 117, in histogram execute(file, File "/Users/Robin/PycharmProjects/imageanalysis_tutorial/venv/lib/python3.10/site-packages/pyclesperanto_prototype/_tier0/_execute.py", line 35, in execute return Backend.get_instance().get().execute(anchor, opencl_kernel_filename, kernel_name, global_size, parameters, prog, constants, image_size_independent_kernel_compilation, device) File "/Users/Robin/PycharmProjects/imageanalysis_tutorial/venv/lib/python3.10/site-packages/pyclesperanto_prototype/_tier0/_opencl_backend.py", line 41, in execute return execute(anchor, opencl_kernel_filename, kernel_name, global_size, parameters, prog, constants, image_size_independent_kernel_compilation, device) File "/Users/Robin/PycharmProjects/imageanalysis_tutorial/venv/lib/python3.10/site-packages/pyclesperanto_prototype/_tier0/_opencl_execute.py", line 311, in execute prog = device.program_from_source("\n".join(defines)) File "/Users/Robin/PycharmProjects/imageanalysis_tutorial/venv/lib/python3.10/site-packages/pyclesperanto_prototype/_tier0/_device.py", line 28, in program_from_source return OCLProgram(src_str=source, dev=self) File "/Users/Robin/PycharmProjects/imageanalysis_tutorial/venv/lib/python3.10/site-packages/pyclesperanto_prototype/_tier0/_program.py", line 28, in init self.build(options=build_options) File "/Users/Robin/PycharmProjects/imageanalysis_tutorial/venv/lib/python3.10/site-packages/pyopencl/init.py", line 535, in build self._prg, was_cached = self._build_and_catch_errors( File "/Users/Robin/PycharmProjects/imageanalysis_tutorial/venv/lib/python3.10/site-packages/pyopencl/init.py", line 583, in _build_and_catch_errors raise err pyopencl._cl.RuntimeError: clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE

Build on <pyopencl.Device 'HD Graphics 4000' on 'Apple' at 0x1024400>:

:28:26: warning: unknown OpenCL extension 'cl_amd_printf' - ignoring #pragma OPENCL EXTENSION cl_amd_printf : enable ^ :596:16: warning: implicit conversion from 'long long' to 'uint' (aka 'unsigned int') changes value from 18446744073709551615 to 4294967295 return 18446744073709551615; ~~~~~~ ^~~~~~~~~~~~~~~~~~~~ :606:16: warning: implicit conversion from 'long' to 'int' changes value from 9223372036854775807 to -1 return 9223372036854775807; ~~~~~~ ^~~~~~~~~~~~~~~~~~~ :609:16: warning: implicit conversion from 'long long' to 'int' changes value from -9223372036854775808 to 0 return -9223372036854775808 ; ~~~~~~ ^~~~~~~~~~~~~~~~~~~~ :668:22: error: call to 'convert_uint_sat' is ambiguous indx_x = convert_uint_sat(( (clr - minimum) * (float)(GET_IMAGE_WIDTH(dst_histogram) - 1)) / range + 0.5); ^~~~~~~~~~~~~~~~ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4188:20: note: candidate function __CLFN_CONVERT_EXT(convert_uint, _sat, uint); ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4104:65: note: expanded from macro '__CLFN_CONVERT_EXT' #define __CLFN_CONVERT_EXT(name, ext, rtype) rtype __OVERLOAD__ name##ext( uchar a); \ ^ :75:1: note: expanded from macro 'convert_uint' convert_uint_sat ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4188:20: note: candidate function __CLFN_CONVERT_EXT(convert_uint, _sat, uint); ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4105:20: note: expanded from macro '__CLFN_CONVERT_EXT' rtype __OVERLOAD__ name##ext( ushort a); \ ^ :76:1: note: expanded from macro 'convert_uint' convert_uint_sat ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4188:20: note: candidate function __CLFN_CONVERT_EXT(convert_uint, _sat, uint); ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4106:20: note: expanded from macro '__CLFN_CONVERT_EXT' rtype __OVERLOAD__ name##ext( uint a); \ ^ :77:1: note: expanded from macro 'convert_uint' convert_uint_sat ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4188:20: note: candidate function __CLFN_CONVERT_EXT(convert_uint, _sat, uint); ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4107:20: note: expanded from macro '__CLFN_CONVERT_EXT' rtype __OVERLOAD__ name##ext( ulong a); \ ^ :78:1: note: expanded from macro 'convert_uint' convert_uint_sat ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4188:20: note: candidate function __CLFN_CONVERT_EXT(convert_uint, _sat, uint); ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4108:20: note: expanded from macro '__CLFN_CONVERT_EXT' rtype __OVERLOAD__ name##ext( char a); \ ^ :79:1: note: expanded from macro 'convert_uint' convert_uint_sat ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4188:20: note: candidate function __CLFN_CONVERT_EXT(convert_uint, _sat, uint); ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4109:20: note: expanded from macro '__CLFN_CONVERT_EXT' rtype __OVERLOAD__ name##ext( short a); \ ^ :80:1: note: expanded from macro 'convert_uint' convert_uint_sat ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4188:20: note: candidate function __CLFN_CONVERT_EXT(convert_uint, _sat, uint); ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4110:20: note: expanded from macro '__CLFN_CONVERT_EXT' rtype __OVERLOAD__ name##ext( int a); \ ^ :81:1: note: expanded from macro 'convert_uint' convert_uint_sat ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4188:20: note: candidate function __CLFN_CONVERT_EXT(convert_uint, _sat, uint); ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4111:20: note: expanded from macro '__CLFN_CONVERT_EXT' rtype __OVERLOAD__ name##ext( long a); \ ^ :82:1: note: expanded from macro 'convert_uint' convert_uint_sat ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4188:20: note: candidate function __CLFN_CONVERT_EXT(convert_uint, _sat, uint); ^ /System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h:4112:20: note: expanded from macro '__CLFN_CONVERT_EXT' rtype __OVERLOAD__ name##ext( float a); \ ^ :83:1: note: expanded from macro 'convert_uint' convert_uint_sat ^ (options: -I /Users/Robin/PycharmProjects/imageanalysis_tutorial/venv/lib/python3.10/site-packages/pyopencl/cl) (source saved as /var/folders/21/n6xrfwks7lz66vy13mzsvcjr0000gn/T/tmpo0mfl46t.cl)
haesleinhuepf commented 10 months ago

I'll take closer look soon.

As a potential workaround: Can you please try calling cle.select_device("CPU") at the beginning? I've seen incompatible GPUs in older Macs and this helped then... Let me know if it works for you too.

Robin1em commented 10 months ago

That worked, thank you very much!