NVIDIA-developer-blog / code-samples

Source code examples from the Parallel Forall Blog
BSD 3-Clause "New" or "Revised" License
1.24k stars 633 forks source link

Can't Detecting CUDA compiler ABI #47

Closed enemy1205 closed 1 year ago

enemy1205 commented 1 year ago

When I try to make the test case with Cmake, I met this error:

[cmake] -- The CUDA compiler identification is unknown
[cmake] -- Detecting CUDA compiler ABI info
[cmake] -- Detecting CUDA compiler ABI info - failed
[cmake] -- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc
[cmake] -- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc - broken
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "/home/XXX/文档/test/cuda/build/CMakeFiles/CMakeOutput.log".
[cmake] See also "/home/XXX/文档/test/cuda/build/CMakeFiles/CMakeError.log".
[cmake] CMake Error at /usr/local/share/cmake-3.22/Modules/CMakeTestCUDACompiler.cmake:56 (message):
[cmake]   The CUDA compiler
[cmake] 
[cmake]     "/usr/local/cuda/bin/nvcc"
[cmake] 
[cmake]   is not able to compile a simple test program.
[cmake] 
[cmake]   It fails with the following output:
[cmake] 
[cmake]     Change Dir: /home/XXX/文档/test/cuda/build/CMakeFiles/CMakeTmp
[cmake]     
[cmake]     Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_77547/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_77547.dir/build.make CMakeFiles/cmTC_77547.dir/build
[cmake]     gmake[1]: 进入目录“/home/XXX/文档/test/cuda/build/CMakeFiles/CMakeTmp”
[cmake]     Building CUDA object CMakeFiles/cmTC_77547.dir/main.cu.o
[cmake]     /usr/local/cuda/bin/nvcc      -c /home/XXX/文档/test/cuda/build/CMakeFiles/CMakeTmp/main.cu -o CMakeFiles/cmTC_77547.dir/main.cu.o
[cmake]     /usr/include/stdio.h(189): error: attribute "__malloc__" does not take arguments
[cmake]     
[cmake]     /usr/include/stdio.h(201): error: attribute "__malloc__" does not take arguments
[cmake]     
[cmake]     /usr/include/stdio.h(223): error: attribute "__malloc__" does not take arguments
[cmake]     
[cmake]     /usr/include/stdio.h(260): error: attribute "__malloc__" does not take arguments
[cmake]     
[cmake]     /usr/include/stdio.h(285): error: attribute "__malloc__" does not take arguments
[cmake]     
[cmake]     /usr/include/stdio.h(294): error: attribute "__malloc__" does not take arguments
[cmake]     
[cmake]     /usr/include/stdio.h(303): error: attribute "__malloc__" does not take arguments
[cmake]     
[cmake]     /usr/include/stdio.h(309): error: attribute "__malloc__" does not take arguments
[cmake]     
[cmake]     /usr/include/stdio.h(315): error: attribute "__malloc__" does not take arguments
[cmake]     
[cmake]     /usr/include/stdio.h(830): error: attribute "__malloc__" does not take arguments
[cmake]     
[cmake]     /usr/include/stdlib.h(566): error: attribute "__malloc__" does not take arguments
[cmake]     
[cmake]     /usr/include/stdlib.h(570): error: attribute "__malloc__" does not take arguments
[cmake]     
[cmake]     /usr/include/stdlib.h(799): error: attribute "__malloc__" does not take arguments
[cmake]     
[cmake]     13 errors detected in the compilation of "/home/XXX/文档/test/cuda/build/CMakeFiles/CMakeTmp/main.cu".
[cmake]     gmake[1]: *** [CMakeFiles/cmTC_77547.dir/build.make:78:CMakeFiles/cmTC_77547.dir/main.cu.o] 错误 1
[cmake]     gmake[1]: 离开目录“/home/XXX/文档/test/cuda/build/CMakeFiles/CMakeTmp”
[cmake]     gmake: *** [Makefile:127:cmTC_77547/fast] 错误 2

I think the main reason is Detecting CUDA compiler ABI info - failed The CMakeLists begin with below:

cmake_minimum_required(VERSION 3.10)
project(cmake_and_cuda LANGUAGES CXX CUDA)
find_package(CUDA)

Test environment:

lix19937 commented 1 year ago

Maybe g++/gcc version not compatible,
Also can see https://forums.developer.nvidia.com/t/cuda-11-5-samples-throw-multiple-error-attribute-malloc-does-not-take-arguments/192750

harrism commented 1 year ago

Which developer blog post or code sample directory are you referring to? This is a bit of a large monorepo, so please be specific.

enemy1205 commented 1 year ago

Maybe g++/gcc version not compatible, Also can see https://forums.developer.nvidia.com/t/cuda-11-5-samples-throw-multiple-error-attribute-malloc-does-not-take-arguments/192750

Thanks for your reply, I have since found out that this is indeed the problem, only newer CUDA supports gcc 11 and above