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

build itk with ITK_USE_CUFFTW ITK_USE_GPU ON gets error #3744

Open
zhusihan-python opened this issue Nov 15, 2022 · 14 comments
Open

build itk with ITK_USE_CUFFTW ITK_USE_GPU ON gets error #3744

zhusihan-python opened this issue Nov 15, 2022 · 14 comments
Labels
type:Compiler Compiler support or related warnings

Comments

@zhusihan-python
Copy link

zhusihan-python commented Nov 15, 2022

build itk master on windows 10 cmake 3.23.1 vs 2022 cuda 11.8 got errors

Description

88f033127f588834b1041ee3831050a

Steps to Reproduce

1、set option ITK_USE_GPU=ON ITK_USE_CUFFTW=ON in CmakeList.txt
2、configure cmake
18af6a41eee9b13f8c0d019c5a6927b

got some warnings as below
4751fbde926bdac8f18a81189e33f84

46fcba9965dc1a67254aace213e35be

all wrap_* has been turn on, still got the warnings, so i just ignore it and continue generate

Expected behavior

build successful, then i can build itk montage using cufft acclerated itk

Actual behavior

build failed

Error	LNK2019	unresolved external symbol "public: static void __cdecl itk::FFTWFFTImageFilterInitFactory::RegisterFactories(void)" (?RegisterFactories@FFTWFFTImageFilterInitFactory@itk@@SAXXZ) referenced in function _wrap_itkFFTWFFTImageFilterInitFactory_RegisterOneFactory	ITKFFTPython	D:\build_itk_new\Wrapping\Modules\ITKFFT\itkFFTWFFTImageFilterInitFactoryPython.obj	1	

Severity	Code	Description	Project	File	Line	Suppression State
Error	LNK2019	unresolved external symbol "protected: __cdecl itk::FFTWFFTImageFilterInitFactory::FFTWFFTImageFilterInitFactory(void)" (??0FFTWFFTImageFilterInitFactory@itk@@IEAA@XZ) referenced in function "public: static class itk::SmartPointer<class itk::FFTWFFTImageFilterInitFactory> __cdecl itk::FFTWFFTImageFilterInitFactory::New(void)" (?New@FFTWFFTImageFilterInitFactory@itk@@SA?AV?$SmartPointer@VFFTWFFTImageFilterInitFactory@itk@@@2@XZ)	ITKFFTPython	D:\build_itk_new\Wrapping\Modules\ITKFFT\itkFFTWFFTImageFilterInitFactoryPython.obj	1	

Severity	Code	Description	Project	File	Line	Suppression State
Error	LNK1120	2 unresolved externals	ITKFFTPython	D:\build_itk_new\Wrapping\Generators\Python\itk\_ITKFFTPython.pyd	1	

Severity	Code	Description	Project	File	Line	Suppression State
Error	MSB8066	Custom build for 'D:\build_itk_new\CMakeFiles\44df38219fcd6d646b4dd91a924288b1\itk-stub-files.rule' exited with code 1.	itk-stub-files	D:\softwares\visualStudio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets	245	

Reproducibility

Versions

master branch commit id 38696b2

Environment

windows 10 cmake 3.23.1 vs 2022 cuda 11.8 python 3.10.8

Additional Information

@zhusihan-python zhusihan-python added the type:Compiler Compiler support or related warnings label Nov 15, 2022
@dzenanz
Copy link
Member

dzenanz commented Nov 15, 2022

None of your images have uploaded properly.

@zhusihan-python
Copy link
Author

None of your images have uploaded properly.

sor, i have updated the images

@thewtex
Copy link
Member

thewtex commented Nov 16, 2022

@zhusihan-python thanks for the report.

i can build itk montage using cufft acclerated itk

We are finalizing itk-5.3.0, at which time we will build packages for itk-montage but also itk-vkfftbackend, which provides GPU acceleration and you will be able to pip install both.

@dzenanz
Copy link
Member

dzenanz commented Nov 16, 2022

It looks like the problem is that GPU filters are not wrapped for Python. I guess that Matt's suggested solution is easier.

@zhusihan-python
Copy link
Author

It looks like the problem is that GPU filters are not wrapped for Python. I guess that Matt's suggested solution is easier.

Sir dzenaz, i tried to set wrap_python to OFF, still got the same error, i notice that the tag 5.3.0 is released yesterday, i tried on this tag, got the same build warnings and errors too, just FYI.

@dzenanz
Copy link
Member

dzenanz commented Nov 25, 2022

referenced in function _wrap_itkFFTWFFTImageFilterInitFactory_RegisterOneFactory

This is clearly Python-related. Did you turn off ITK_WRAP_PYTHON?

Also possibly look at #1809 (comment).

@zhusihan-python
Copy link
Author

with ITK_WRAP_PYTHON OFF, ITK_USE_GPU ON, ITK_USE_CUFFTW ON
got errors as below:

471>FFTImageFilterFourierDomainFiltering.obj : error LNK2001: unresolved external symbol "void __cdecl itk::FFTWFFTImageFilterInitFactoryRegister__Private(void)" (?FFTWFFTImageFilterInitFactoryRegister__Private@itk@@YAXXZ)
471>F:\build_itk\bin\Release\FFTImageFilterFourierDomainFiltering.exe : fatal error LNK1120: 1 unresolved externals
472>FFTImageFilter.obj : error LNK2001: unresolved external symbol "void __cdecl itk::FFTWFFTImageFilterInitFactoryRegister__Private(void)" (?FFTWFFTImageFilterInitFactoryRegister__Private@itk@@YAXXZ)
472>F:\build_itk\bin\Release\FFTImageFilter.exe : fatal error LNK1120: 1 unresolved externals
471>Done building project "FFTImageFilterFourierDomainFiltering.vcxproj" -- FAILED.
492>------ Build started: Project: DeformableRegistration7, Configuration: Release x64 ------
473>FFTDirectInverse2.obj : error LNK2001: unresolved external symbol "void __cdecl itk::FFTWFFTImageFilterInitFactoryRegister__Private(void)" (?FFTWFFTImageFilterInitFactoryRegister__Private@itk@@YAXXZ)
473>F:\build_itk\bin\Release\FFTDirectInverse2.exe : fatal error LNK1120: 1 unresolved externals
491>E:\projects\ITK\Modules\Filtering\Smoothing\include\itkRecursiveGaussianImageFilter.h(1,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
491>E:\projects\ITK\Modules\Filtering\ImageFilterBase\include\itkRecursiveSeparableImageFilter.h(1,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
473>Done building project "FFTDirectInverse2.vcxproj" -- FAILED.
493>------ Build started: Project: DeformableRegistration6, Configuration: Release x64 ------
472>Done building project "FFTImageFilter.vcxproj" -- FAILED.

486>DicomPrintPatientInformation.vcxproj -> F:\build_itk\bin\Release\DicomPrintPatientInformation.exe
474>FFTDirectInverse.obj : error LNK2001: unresolved external symbol "void __cdecl itk::FFTWFFTImageFilterInitFactoryRegister__Private(void)" (?FFTWFFTImageFilterInitFactoryRegister__Private@itk@@YAXXZ)
497>------ Build started: Project: DeformableRegistration2, Configuration: Release x64 ------
474>F:\build_itk\bin\Release\FFTDirectInverse.exe : fatal error LNK1120: 1 unresolved externals
492>DeformableRegistration7.cxx
497>Building Custom Rule E:/projects/ITK/Examples/RegistrationITKv4/CMakeLists.txt
477>EllipseSpatialObject.vcxproj -> F:\build_itk\bin\Release\EllipseSpatialObject.exe
474>Done building project "FFTDirectInverse.vcxproj" -- FAILED.

then add ITK_USE_FFTWD_DEFAULT ON, ITK_USE_FFTWF_DEFAULT ON, ITK_USE_SYSTEM_FFTW_DEFAULT ON build success.
with ITK_WRAP_PYTHON ON still got errors.
branch master commit

@dzenanz
Copy link
Member

dzenanz commented Nov 28, 2022

MKL and cuFFT impersonate FFTW, so ITK_USE_FFTWD_DEFAULT ON, ITK_USE_FFTWF_DEFAULT ON, ITK_USE_SYSTEM_FFTW_DEFAULT ON are needed as a side-effect of build-system simplification.

I don't remember whether Python is supposed to work with cuFFTW, or even just any GPU filters. @tbirdso and/or @thewtex might know.

@tbirdso
Copy link
Contributor

tbirdso commented Nov 28, 2022

@dzenanz yes, FFTW should work with Python. This does sound like a bug.

@tbirdso
Copy link
Contributor

tbirdso commented Nov 29, 2022

Interestingly, in attempting to reproduce with ITK_USE_SYSTEM_FFTW=ON and ITK_USE_GPU=ON on Linux I was able to build successfully but importing ITKFFT fails:

>>> import itk
>>> itk.auto_progress(2)
>>> itk.FFTWForwardFFTImageFilter
Loading ITKPyBase... done
Loading ITKCommon... done
Loading ITKStatistics... done
Loading ITKImageFilterBase... done
Loading ITKTransform... done
Loading ITKImageFunction... done
Loading ITKImageGrid... done
Loading ITKFFT... Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/tom/builds/ITK-base-dev/Wrapping/Generators/Python/itk/support/lazy.py", line 138, in __getattribute__
    base.itk_load_swig_module(module, namespace)
  File "/home/tom/builds/ITK-base-dev/Wrapping/Generators/Python/itk/support/base.py", line 132, in itk_load_swig_module
    l_module = loader.load(swig_module_name)
  File "/home/tom/builds/ITK-base-dev/Wrapping/Generators/Python/itk/support/base.py", line 291, in load
    l_spec.loader.exec_module(l_module)  # pytype: disable=attribute-error
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/tom/builds/ITK-base-dev/Wrapping/Generators/Python/itk/support/../ITKFFTPython.py", line 13, in <module>
    from . import _ITKFFTPython
ImportError: /home/tom/builds/ITK-base-dev/Wrapping/Generators/Python/itk/_ITKFFTPython.so: undefined symbol: _ZTIN3itk29FFTWFFTImageFilterInitFactoryE

@zhusihan-python
Copy link
Author

update
with ITK_WRAP_PYTHON ON, ITK_USE_GPU ON, ITK_USE_CUFFTW ON, ITK_USE_FFTWD_DEFAULT ON, ITK_USE_FFTWF_DEFAULT ON, ITK_USE_SYSTEM_FFTW_DEFAULT ON
compile tag v5.2.1 success on windows 10
then build itk montage and montage examples success

@dzenanz dzenanz closed this as completed Dec 5, 2022
@tbirdso
Copy link
Contributor

tbirdso commented Dec 5, 2022

@dzenanz should this be kept open? My understanding is the build passed for v5.2.1 but failed for v5.3.0.

@dzenanz
Copy link
Member

dzenanz commented Dec 5, 2022

@zhusihan-python can reopen if the issue was not fixed, and further clarify the problem if it is something other than "build passed for v5.2.1 but failed for v5.3.0".

@tbirdso
Copy link
Contributor

tbirdso commented Apr 20, 2023

Re-opening this issue, @zhusihan-python has confirmed in InsightSoftwareConsortium/ITKVkFFTBackend#64 that the issue persists in ITK v5.3.0. Platform and build environment details are available in InsightSoftwareConsortium/ITKVkFFTBackend#64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:Compiler Compiler support or related warnings
Projects
None yet
Development

No branches or pull requests

4 participants