Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU filters fail when invoked from Python #4846

Open
allemangD opened this issue Sep 10, 2024 · 1 comment
Open

GPU filters fail when invoked from Python #4846

allemangD opened this issue Sep 10, 2024 · 1 comment
Labels
type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances

Comments

@allemangD
Copy link
Contributor

Creating this to track the remaining issue after #4842. See the description there for details.

Description

Python-wrapped GPU filters fail with OpenCL Error : CL_INVALID_MEM_OBJECT; they work correctly from C++.

Steps to Reproduce

Build ITK with GPU and Python wrapping; run existing itkGPU* test suite.

cmake -DITK_WRAP_PYTHON=ON -DITK_USE_GPU=ON ...
cmake --build ...
ctest -R itkGPU
Test project ...
      Start  959: itkGPUGradientAnisotropicDiffusionImageFilterTest2D
 1/24 Test  #959: itkGPUGradientAnisotropicDiffusionImageFilterTest2D .........   Passed    0.15 sec
      Start  960: itkGPUGradientAnisotropicDiffusionImageFilterTest3D
 2/24 Test  #960: itkGPUGradientAnisotropicDiffusionImageFilterTest3D .........   Passed    0.42 sec
...
      Start 3151: itkGPUGradientAnisotropicDiffusionImageFilterPythonTest2D
20/24 Test #3151: itkGPUGradientAnisotropicDiffusionImageFilterPythonTest2D ...   Passed    4.43 sec
      Start 3152: itkGPUGradientAnisotropicDiffusionImageFilterPythonTest3D
21/24 Test #3152: itkGPUGradientAnisotropicDiffusionImageFilterPythonTest3D ...***Failed    0.81 sec
...
The following tests FAILED:
	3152 - itkGPUGradientAnisotropicDiffusionImageFilterPythonTest3D (Failed)
	3157 - itkGPUMeanImageFilterPythonTest2D (Failed)

There are also filters which do not currently have Python wrapping tests; the issue also affects these. For example itkGPUDiscreteGaussianImageFilter:

>>> import numpy as np
>>> import itk
>>> im = itk.GetImageFromArray(np.random.normal(size=(50,50,50)).astype('f'))
>>> gpu_im = itk.cast_image_filter(im, ttype=(itk.Image[itk.F, 3], itk.GPUImage[itk.F, 3]))
Platform  : NVIDIA CUDA
...
>>> gpu_im.UpdateBuffers()
>>> blur = itk.gpu_discrete_gaussian_image_filter(gpu_im, variance=2)
Platform  : NVIDIA CUDA
...
Traceback (most recent call last):
...
  File ".../Wrapping/Generators/Python/itk/ITKCommonBasePython.py", line 3100, in UpdateLargestPossibleRegion
    return _ITKCommonBasePython.itkProcessObject_UpdateLargestPossibleRegion(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: .../ITK/Modules/Core/GPUCommon/include/itkGPUKernelManager.h:130:
OpenCL Error : CL_INVALID_MEM_OBJECT

Note the cast to GPUImage succeeds and the first UpdateBuffers() succeeds. The cast outputs OpenCL platform information. The failure occurs only in filter Update().

Versions

Checked ITK 5.4 and current (as of #4842) master f8d8cf9.

Python 3.9.19, 3.12.4

Environment

  • Ubuntu 22.04
  • CMake 3.28.1
  • g++ 11.4.0
  • nvidia-driver-550 (RTX 4090)

cc @jcfr since you mentioned interest.

@allemangD allemangD added the type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances label Sep 10, 2024
Copy link

Thank you for contributing an issue! 🙏

Welcome to the ITK community! 🤗👋☀️

We are glad you are here and appreciate your contribution. Please keep in mind our community participation guidelines. 📜
Also, please check existing open issues and consider discussion on the ITK Discourse. 📖

This is an automatic message. Allow for time for the ITK community to be able to read the issue and comment on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances
Projects
None yet
Development

No branches or pull requests

1 participant