mphowardlab / azplugins

A HOOMD-blue component for soft matter simulations.
BSD 3-Clause "New" or "Revised" License
20 stars 12 forks source link

Error with CUB while compiling the plugin #66

Closed edwinb-ai closed 2 years ago

edwinb-ai commented 2 years ago

Hello, thanks for the plugin!

I have tried compiling it under Ubuntu, with CUDA version 11.5 and the newest version of Thrust (v2.0), and I have the following configuration results when I run cmake

-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /home/zhangyh/opt/miniconda3/bin/python (found version "3.7.13") 
-- Found HOOMD: /home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd (found suitable version "2.9.0", minimum required is "2.6.0") 
-- Found PythonInterp: /home/zhangyh/opt/miniconda3/bin/python (found suitable version "3.7.13", minimum required is "3") 
-- Found PythonLibs: /home/zhangyh/opt/miniconda3/lib/libpython3.7m.so
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found CUDA: /usr/local/cuda-11.5 (found suitable version "11.5", minimum required is "8.0") 
-- Found Thrust: /usr/local/cuda-11.5/include (found suitable version "2.0.0", minimum required is "1.5.0") 
-- Found cusolver: /usr/local/cuda-11.5/lib64/libcusolver.so
-- Setting build type to 'Release' as none was specified.
-- Found TBB: /home/zhangyh/opt/miniconda3/lib/libtbb.so (found suitable version "2020.2", minimum required is "4.3") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/zhangyh/Downloads/azplugins-main/build

However, when I run make install, I find the following errors, and don't know what to do from there.

[  1%] Building NVCC (Device) object azplugins/CMakeFiles/cuda_compile_1.dir/cuda_compile_1_generated_SinusoidalExpansionConstrictionFillerGPU.cu.o
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
[  2%] Building NVCC (Device) object azplugins/CMakeFiles/cuda_compile_1.dir/cuda_compile_1_generated_AnisoPairPotentialTwoPatchMorse.cu.o
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
In file included from /usr/local/cuda-11.5/include/thrust/detail/config/config.h:27,
                 from /usr/local/cuda-11.5/include/thrust/detail/config.h:23,
                 from /usr/local/cuda-11.5/include/thrust/iterator/iterator_facade.h:35,
                 from /home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/extern/cub/cub/device/../iterator/arg_index_input_iterator.cuh:48,
                 from /home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/extern/cub/cub/device/device_reduce.cuh:41,
                 from /home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/extern/cub/cub/cub.cuh:53,
                 from /home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh:14,
                 from /home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/md/AnisoPotentialPairGPU.cuh:14,
                 from /home/zhangyh/Downloads/azplugins-main/azplugins/AnisoPairPotentials.cuh:16,
                 from /home/zhangyh/Downloads/azplugins-main/azplugins/AnisoPairPotentialTwoPatchMorse.cu:5:
/usr/local/cuda-11.5/include/thrust/detail/config/cpp_dialect.h:131:13: warning: Thrust requires at least C++14. C++11 is deprecated but still supported. C++11 support will be removed in a future release. Define THRUST_IGNORE_DEPRECATED_CPP_DIALECT to suppress this message.
  131 |      THRUST_COMPILER_DEPRECATION_SOFT(C++14, C++11);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                                           
In file included from /usr/local/cuda-11.5/include/thrust/system/cuda/config.h:33,
                 from /usr/local/cuda-11.5/include/thrust/system/cuda/detail/execution_policy.h:35,
                 from /usr/local/cuda-11.5/include/thrust/iterator/detail/device_system_tag.h:23,
                 from /usr/local/cuda-11.5/include/thrust/iterator/detail/iterator_facade_category.h:22,
                 from /usr/local/cuda-11.5/include/thrust/iterator/iterator_facade.h:37,
                 from /home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/extern/cub/cub/device/../iterator/arg_index_input_iterator.cuh:48,
                 from /home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/extern/cub/cub/device/device_reduce.cuh:41,
                 from /home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/extern/cub/cub/cub.cuh:53,
                 from /home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh:14,
                 from /home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/md/AnisoPotentialPairGPU.cuh:14,
                 from /home/zhangyh/Downloads/azplugins-main/azplugins/AnisoPairPotentials.cuh:16,
                 from /home/zhangyh/Downloads/azplugins-main/azplugins/AnisoPairPotentialTwoPatchMorse.cu:5:
/usr/local/cuda-11.5/include/cub/util_namespace.cuh:46:2: error: #error CUB requires a definition of CUB_NS_QUALIFIER when CUB_NS_PREFIX/POSTFIX are defined.
   46 | #error CUB requires a definition of CUB_NS_QUALIFIER when CUB_NS_PREFIX/POSTFIX are defined.
      |  ^~~~~
CMake Error at cuda_compile_1_generated_AnisoPairPotentialTwoPatchMorse.cu.o.Release.cmake:220 (message):
  Error generating
  /home/zhangyh/Downloads/azplugins-main/build/azplugins/CMakeFiles/cuda_compile_1.dir//./cuda_compile_1_generated_AnisoPairPotentialTwoPatchMorse.cu.o

make[2]: *** [azplugins/CMakeFiles/_azplugins.dir/build.make:65: azplugins/CMakeFiles/cuda_compile_1.dir/cuda_compile_1_generated_AnisoPairPotentialTwoPatchMorse.cu.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:192: azplugins/CMakeFiles/_azplugins.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

Any help would be greatly appreciated. :)

mphoward commented 2 years ago

Thanks for the bug report! Have you tried bumping up your version to HOOMD 2.9.7? I see you're using HOOMD 2.9.0, but there were some changes made in 2.9.7 to support CUDA 11.5:

https://github.com/glotzerlab/hoomd-blue/blob/trunk-minor/CHANGELOG.rst#v297-2021-08-03

We currently test our builds with HOOMD 2.9.7 and CUDA 11.5 and have not seen this before. If that does not work / run for you though, let me know. I have a pretty good idea of what would be needed to fix it.

edwinb-ai commented 2 years ago

Hi! Thanks for the quick reply. 😄

I have now updated HOOMD to version 2.9.7 and configured the build once more

-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /home/zhangyh/opt/miniconda3/bin/python (found version "3.7.13") 
-- Found HOOMD: /home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd (found suitable version "2.9.7", minimum required is "2.6.0") 
-- Found PythonInterp: /home/zhangyh/opt/miniconda3/bin/python (found suitable version "3.7.13", minimum required is "3") 
-- Found PythonLibs: /home/zhangyh/opt/miniconda3/lib/libpython3.7m.so
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found CUDA: /usr/local/cuda-11.5 (found suitable version "11.5", minimum required is "8.0") 
-- Found Thrust: /usr/local/cuda-11.5/include (found suitable version "1.13.1", minimum required is "1.5.0") 
-- Found cusolver: /usr/local/cuda-11.5/lib64/libcusolver.so
-- Setting build type to 'Release' as none was specified.
-- Found TBB: /home/zhangyh/opt/miniconda3/lib/libtbb.so (Required is at least version "4.3") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/zhangyh/Downloads/azplugins/build

And the result is the following

[  1%] Building NVCC (Device) object azplugins/CMakeFiles/cuda_compile_1.dir/cuda_compile_1_generated_SinusoidalExpansionConstrictionFillerGPU.cu.o
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
[  2%] Building NVCC (Device) object azplugins/CMakeFiles/cuda_compile_1.dir/cuda_compile_1_generated_AnisoPairPotentialTwoPatchMorse.cu.o
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(119): error: explicit type is missing ("int" assumed)

/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(119): error: expected a ";"

/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(120): error: a class or namespace qualified name is required

/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(120): error: global-scope qualifier (leading "::") is not allowed

/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(120): error: expected a ";"

/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(349): error: explicit type is missing ("int" assumed)

/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(349): error: expected a ";"

/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(350): error: a class or namespace qualified name is required

/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(350): error: global-scope qualifier (leading "::") is not allowed

/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(350): error: expected a ";"

/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(354): error: name followed by "::" must be a class or namespace name

/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(354): error: the global scope has no "CATEGORY"

/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(354): error: name followed by "::" must be a class or namespace name

/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(354): error: name followed by "::" must be a class or namespace name

/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(354): error: the global scope has no "CATEGORY"

/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(354): error: name followed by "::" must be a class or namespace name

/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/WarpTools.cuh(63): error: name followed by "::" must be a class or namespace name
          detected during:
            instantiation of "void gpu_compute_pair_aniso_forces_kernel<evaluator,shift_mode,compute_virial,tpp>(Scalar4 *, Scalar4 *, Scalar *, unsigned int, unsigned int, const Scalar4 *, const Scalar *, const Scalar *, const Scalar4 *, const unsigned int *, BoxDim, const unsigned int *, const unsigned int *, const unsigned int *, const evaluator::param_type *, const evaluator::shape_param_type *, const Scalar *, unsigned int, unsigned int, unsigned int) [with evaluator=azplugins::detail::AnisoPairEvaluatorTwoPatchMorse, shift_mode=0U, compute_virial=1U, tpp=32]" 
/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/md/AnisoPotentialPairGPU.cuh(443): here
            instantiation of "void AnisoPairForceComputeKernel<evaluator, shift_mode, compute_virial, tpp>::launch(const a_pair_args_t &, std::pair<unsigned int, unsigned int>, const evaluator::param_type *, const evaluator::shape_param_type *) [with evaluator=azplugins::detail::AnisoPairEvaluatorTwoPatchMorse, shift_mode=0U, compute_virial=1U, tpp=32]" 
/home/zhangyh/opt/miniconda3/lib/python3.7/site-packages/hoomd/include/hoomd/md/AnisoPotentialPairGPU.cuh(546): here
            instantiation of "cudaError_t gpu_compute_pair_aniso_forces<evaluator>(const a_pair_args_t &, const evaluator::param_type *, const evaluator::shape_param_type *) [with evaluator=azplugins::detail::AnisoPairEvaluatorTwoPatchMorse]" 
/home/zhangyh/Downloads/azplugins/azplugins/AnisoPairPotentials.cuh(56): here
            instantiation of "cudaError_t azplugins::gpu::compute_aniso_pair_potential<evaluator>(const a_pair_args_t &, const evaluator::param_type *, const evaluator::shape_param_type *) [with evaluator=azplugins::detail::AnisoPairEvaluatorTwoPatchMorse]" 
/home/zhangyh/Downloads/azplugins/azplugins/AnisoPairPotentialTwoPatchMorse.cu(13): here

17 errors detected in the compilation of "/home/zhangyh/Downloads/azplugins/azplugins/AnisoPairPotentialTwoPatchMorse.cu".
CMake Error at cuda_compile_1_generated_AnisoPairPotentialTwoPatchMorse.cu.o.Release.cmake:280 (message):
  Error generating file
  /home/zhangyh/Downloads/azplugins/build/azplugins/CMakeFiles/cuda_compile_1.dir//./cuda_compile_1_generated_AnisoPairPotentialTwoPatchMorse.cu.o

make[2]: *** [azplugins/CMakeFiles/_azplugins.dir/build.make:65: azplugins/CMakeFiles/cuda_compile_1.dir/cuda_compile_1_generated_AnisoPairPotentialTwoPatchMorse.cu.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:192: azplugins/CMakeFiles/_azplugins.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
mphoward commented 2 years ago

Thanks, I have had someone else report a similar bug, and I think the cause is related to a change in wrapping the thrust/cub namespaces. We build HOOMD from source in tests rather than relying on the conda-forge version, so I will see if I can reproduce this locally and fix.

mphoward commented 2 years ago

Could you try to checkout the branch in PR #67 and see if that fixes your error? However, I should ask: are you building HOOMD from source or using Anaconda? There seems to be some issues using the conda version on the GPU:

https://groups.google.com/g/hoomd-users/c/b7gjGwwi1PY

edwinb-ai commented 2 years ago

Hey! Thanks a lot, I checked out the branch and it now works perfectly. I had to compile HOOMD and the plugin separately, and it now works as expected. Thank you! 😄