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

patch_morphology build failure with external BLAS #153

Open
bcdarwin opened this issue May 16, 2022 · 5 comments
Open

patch_morphology build failure with external BLAS #153

bcdarwin opened this issue May 16, 2022 · 5 comments

Comments

@bcdarwin
Copy link
Contributor

bcdarwin commented May 16, 2022

Building the toolkit (roughly 1.9.18-develop) on Rocky Linux 8.5 (RHEL 8 derivative) fails with:

[ 20%] Performing build step for 'patch_morphology'
[  8%] Built target itk_merge_discrete_labels
[ 17%] Built target itk_merge_labels
[ 26%] Built target itk_patch_morphology_mc
[ 34%] Built target itk_patch_morphology
[ 39%] Building C object src/CMakeFiles/itk_patch_grading.dir/3rd_party/nnls/nnls.c.o
/home/hpcdarw1/rds/hpc-work/tools/builds/minc-toolkit-v2/patch_morphology/src/3rd_party/nnls/nnls.c:20:10: fatal error: lapacke.h: No such file or directory
 #include <lapacke.h>

However,

$ locate lapacke.h
/usr/include/lapacke/lapacke.h
/usr/include/openblas/lapacke.h
/usr/share/man/man3/lapacke.h.3.gz

I assume this is a CMake issue, but the MINC toolkit doesn't expose CMake options to set the LAPACK location.

@gdevenyi
Copy link
Contributor

What was your cmake config? I found if you're doing BLAS stuff you can't switch it on and reconfigure, it must be set from the first-step.

@bcdarwin
Copy link
Contributor Author

Didn't do any config beyond disabling ANTs (non-default option to build OpenBLAS as part of superbuild also fails in an unrelated way).

@gdevenyi
Copy link
Contributor

I hit the same error an hour after.

@gdevenyi
Copy link
Contributor

This fixes the build for me when using the internal OpenBLAS

diff --git a/cmake-modules/BuildOpenBLAS.cmake b/cmake-modules/BuildOpenBLAS.cmake
index 5e82918..67e9966 100644
--- a/cmake-modules/BuildOpenBLAS.cmake
+++ b/cmake-modules/BuildOpenBLAS.cmake
@@ -93,7 +93,7 @@ macro(build_open_blas install_prefix staging_prefix build_parallel)
             INSTALL_DIR ${staging_prefix}/${install_prefix}
       )
 
-  SET(OpenBLAS_INCLUDE_DIRS ${staging_prefix}/${install_prefix}/include )
+  SET(OpenBLAS_INCLUDE_DIRS ${staging_prefix}/${install_prefix}/include/openblas )
   SET(OpenBLAS_LIBRARIES    ${staging_prefix}/${install_prefix}/lib${LIB_SUFFIX}/libopenblas.so  )
   SET(OpenBLAS_LIBRARY      ${OpenBLAS_LIBRARIES})
   SET(OpenBLAS_DIR          ${staging_prefix}/${install_prefix}/share/cmake/OpenBLAS )
diff --git a/cmake-modules/BuildPatchMorphology.cmake b/cmake-modules/BuildPatchMorphology.cmake
index 31630ef..d538f9a 100644
--- a/cmake-modules/BuildPatchMorphology.cmake
+++ b/cmake-modules/BuildPatchMorphology.cmake
@@ -40,7 +40,8 @@ macro(build_PatchMorphology install_prefix staging_prefix itk_dir)
         -DCMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=${CMAKE_STATIC_LINKER_FLAGS_RELEASE}
         -DCMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO}
         -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-        -DOpenBLAS_INCLUDE_DIR:PATH=${OpenBLAS_INCLUDE_DIRS}
+        -DOpenBLAS_INCLUDE_DIRS:PATH=${OpenBLAS_INCLUDE_DIRS}
+        -DOpenBLAS_LIBRARIES:PATH=${OpenBLAS_LIBRARIES}
         -DOpenBLAS_LIBRARY:PATH=${OpenBLAS_LIBRARY}
         -DCMAKE_DISABLE_FIND_PACKAGE_OpenBLAS:BOOL=ON
         -DOpenBLAS_DIR:PATH=${OpenBLAS_DIR}

@bcdarwin I think this line
https://github.com/BIC-MNI/minc-toolkit-v2/blob/develop-1.9.18/cmake-modules/BuildPatchMorphology.cmake#L45
Is probably causing your issue.

Its also possible all these variables need to be changed to BLAS_* etc instead of OpenBLAS_, because as I understand find_package(BLAS) it it exports BLAS_* variables

@gdevenyi
Copy link
Contributor

@bcdarwin I think the issue in your case is also we probably need to add find_package(LAPACK) and handle those directories as well.

In openblas the blas/lapack includes are in the same place, but on ubuntu (and probably your system), these end up in different places, from different packages.

Ubuntu 2204:

/usr/include/x86_64-linux-gnu/openblas-pthread/cblas.h
/usr/include/lapacke.h

I'll try sorting out the non-superbuild-blas after I confirm the superbuild variant works.

P.S. what's your cmake version? I see mentions elsewhere that find_package(BLAS) didn't find OpenBLAS until >3.6

@gdevenyi gdevenyi changed the title patch_morphology build failure patch_morphology build failure with external BLAS May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants