ITK build with TBB

(Hrach) #1

Hi everyone,

I am trying to build ITK-5.0.0 with TBB.
I have already successfully built TBB.
After cmake config I get this error

 Could not find a package configuration file provided by "TBB" with any of
  the following names:

    TBBConfig.cmake
    tbb-config.cmake

  Add the installation prefix of "TBB" to CMAKE_PREFIX_PATH or set "TBB_DIR"
  to a directory containing one of the above files.

I have tried to compile by command line also

-DCMAKE_PREFIX_PATH=/home/hs/Dcuments/TBB \
-DModule_ITKTBB:BOOL=ON \

still the same error.
Can someone tell how to fix this?

Thank you

(Dženan Zukić) #2

TBB is not a normal CMake-managed library. Instead of creating a TBBConfig.cmake file when you build it, they provide a way for you to generate a customized version of TBBConfig.cmake. But the binary release of TBB does contain TBBConfig.cmake, which is what you are supposed to point at when configuring ITK.

@hjmjohnson has tried to convince TBB people to add better CMake support, and might have further suggestions.

(Hrach) #3

But ITK-4.13 did not require TBBConfig.cmake
It only has TBBFind.cmake file.
I want to understand what is the difference between this two versions.
Thank you

(Dženan Zukić) #4

Plain ITK-4.13 did not make use of TBB at all. Only the remote module TBBImageToImageFilter did. And the drawback of FindTBB.cmake approach is necessity of specifying about 20 paths for include directories and release and debug libraries for TBB components (tbb, tbb_malloc, tbbmalloc_proxy etc). Also, there is an outstanding PR which adds back FindTBB.cmake. It would be good if you tested and reviewed that PR - it might be a solution you are looking for.

(Hrach) #5

Right, but 5.0.0 version does not come with FindTBB.cmake file.
How can I generate that file for 5.0.0 version

#6

Would it be possible to use a newer version of TBB? Versions of TBB since about late 2017 come with a TBBConfig.cmake file which does away with the need for the FindTBB.cmake at all.

(Dženan Zukić) #7

@imikejackson Precompiled versions of TBB. He compiled his own.

@nm97 The patch should be easy to apply to 5.0.0. Try to apply it, and use such patched ITK. Then let us know how it went.

(Hrach) #8

I am testing it right now.
And one more question.
When I configure with cmake it has variable with name TBB_MALLOC_PROXY_LIBRARY. Is it required to give path to that file?

(Dženan Zukić) #9

I don’t know. I always gave it the paths to all the libraries that appeared in CMake cache.

(Hrach) #10

I applied patch to 5.0.0, it compiles fine, but for running examples it still causes error

CMake Error at /usr/local/lib/cmake/ITK-5.0/Modules/ITKTBB.cmake:15 (find_package):
  Could not find a package configuration file provided by "TBB" with any of
  the following names:

    TBBConfig.cmake
    tbb-config.cmake

  Add the installation prefix of "TBB" to CMAKE_PREFIX_PATH or set "TBB_DIR"
  to a directory containing one of the above files.  If "TBB" provides a
  separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
  /usr/local/lib/cmake/ITK-5.0/ITKModuleAPI.cmake:76 (include)
  /usr/local/lib/cmake/ITK-5.0/ITKModuleAPI.cmake:31 (itk_module_load)
  /usr/local/lib/cmake/ITK-5.0/ITKModuleAPI.cmake:129 (_itk_module_config_recurse)
  /usr/local/lib/cmake/ITK-5.0/ITKConfig.cmake:82 (itk_module_config)
  CMakeLists.txt:19 (find_package)

how can I test binareies in this case?

(Hrach) #11

And the last question please.
When I am building there is TBB_DIR variable. I can not understand which directory path I have to give to that variable.
Do you have any idea?

(Dženan Zukić) #12

On my Linux computer, TBB_DIR path is /home/dzenan/tbb2019_20190206oss/cmake. I am using binary distribution.

(Hrach) #13

Just to make it clear.
As I understand 4.13 version does not have TBB_DIR variable, so we don’t need to have TBBConfig.cmake file.
And 5.0.0 requires TBBConfig.cmake file.
Am I right?

(Dženan Zukić) #14

ITK 4.13 did not have TBB support. ITK 5.0 has support for TBB, and requires TBBConfig.cmake which comes with newer binary distributions of TBB. TBB also has a procedure to generate TBBConfig.cmake for a TBB you compiled yourself, but that is not easy. PR991 tries to alleviate the restriction of requiring TBBConfig.cmake.

(Dženan Zukić) #15

And you don’t have to build with TBB - that is an optional feature which allows better load balancing, and is supposed to ease general parallel performance, especially when ITK-based program is not the only one making high CPU use.

(Hrach) #16

Right,
I have tried this version already, the problem is I can not run examples to see if library has been built successfully or not, because it anyway needs TBB_DIR( TBBConfig.cmake).
In this case how can i test libraries?

#17

Can you run the prebuilt binaries from Intel? You can download them from Github. https://github.com/intel/tbb/releases The precompiled binaries work with all the compilers that ITK 5 supports so in general this should not be an issue. The only reason I can think of is that your internal IT policy forbids you to download precompiled binaries. Could you elaborate more on why you cannot use the precompiled binaries for TBB?