davisking / dlib

A toolkit for making real world machine learning and data analysis applications in C++
http://dlib.net
Boost Software License 1.0
13.57k stars 3.38k forks source link

[Bug]: CUDA was found but your compiler failed to compile a simple CUDA program so dlib isn't going to use CUDA. #3008

Closed YoucanBaby closed 4 weeks ago

YoucanBaby commented 2 months ago

What Operating System(s) are you seeing this problem on?

Linux (x86-64)

dlib version

19.24.99

Python version

3.10

Compiler

GCC 9.4.0

Expected Behavior

I want to install dlib using CUDA.

When I run the last command, I get the error.

git clone https://github.com/davisking/dlib.git
cd dlib
mkdir build
cd build
cmake .. -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1 

Current Behavior

CUDA was found but your compiler failed to compile a simple CUDA program so dlib isn't going to use CUDA.

-- Found CUDA: /usr (found suitable version "10.1", minimum required is "7.5")
-- Looking for cuDNN install...
-- Found cuDNN: /usr/local/cuda/lib64/libcudnn.so
-- Building a CUDA test project to see if your compiler is compatible with CUDA...
-- *****************************************************************************************************************
-- *** CUDA was found but your compiler failed to compile a simple CUDA program so dlib isn't going to use CUDA. 
-- *** The output of the failed CUDA test compile is shown below: 
-- *** 
-- ***   Change Dir: '/ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build'
   ***   
   ***   Run Build Command(s): /ssd1/anaconda3/envs/sit/lib/python3.10/site-packages/cmake/data/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile
   ***   /ssd1/anaconda3/envs/sit/lib/python3.10/site-packages/cmake/data/bin/cmake -S/ssd1/xyf/personalization/dlib/dlib/cmake_utils/test_for_cuda -B/ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build --check-build-system CMakeFiles/Makefile.cmake 0
   ***   /ssd1/anaconda3/envs/sit/lib/python3.10/site-packages/cmake/data/bin/cmake -E cmake_progress_start /ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build/CMakeFiles /ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build//CMakeFiles/progress.marks
   ***   /usr/bin/make  -f CMakeFiles/Makefile2 all
   ***   make[1]: 进入目录“/ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build”
   ***   /usr/bin/make  -f CMakeFiles/cuda_test.dir/build.make CMakeFiles/cuda_test.dir/depend
   ***   make[2]: 进入目录“/ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build”
   ***   [ 50%] Building NVCC (Device) object CMakeFiles/cuda_test.dir/cuda_test_generated_cuda_test.cu.o
   ***   cd /ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build/CMakeFiles/cuda_test.dir && /ssd1/anaconda3/envs/sit/lib/python3.10/site-packages/cmake/data/bin/cmake -E make_directory /ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build/CMakeFiles/cuda_test.dir//.
   ***   cd /ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build/CMakeFiles/cuda_test.dir && /ssd1/anaconda3/envs/sit/lib/python3.10/site-packages/cmake/data/bin/cmake -D verbose:BOOL=1 -D build_configuration:STRING= -D generated_file:STRING=/ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build/CMakeFiles/cuda_test.dir//./cuda_test_generated_cuda_test.cu.o -D generated_cubin_file:STRING=/ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build/CMakeFiles/cuda_test.dir//./cuda_test_generated_cuda_test.cu.o.cubin.txt -P /ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build/CMakeFiles/cuda_test.dir//cuda_test_generated_cuda_test.cu.o.cmake
   ***   -- Removing /ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build/CMakeFiles/cuda_test.dir//./cuda_test_generated_cuda_test.cu.o
   ***   /ssd1/anaconda3/envs/sit/lib/python3.10/site-packages/cmake/data/bin/cmake -E rm -f /ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build/CMakeFiles/cuda_test.dir//./cuda_test_generated_cuda_test.cu.o
   ***   -- Generating dependency file: /ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build/CMakeFiles/cuda_test.dir//cuda_test_generated_cuda_test.cu.o.NVCC-depend
   ***   /usr/bin/nvcc -M -D__CUDACC__ /ssd1/xyf/personalization/dlib/dlib/cmake_utils/test_for_cuda/cuda_test.cu -o /ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build/CMakeFiles/cuda_test.dir//cuda_test_generated_cuda_test.cu.o.NVCC-depend -ccbin /usr/bin/cc -m64 -DDLIB_USE_CUDA -arch=sm_50 -std=c++14 -D__STRICT_ANSI__ -D_MWAITXINTRIN_H_INCLUDED -D_FORCE_INLINES -DNVCC -I/usr/include -I/ssd1/xyf/personalization/dlib/dlib/cmake_utils/test_for_cuda/../../cuda
   ***   In file included from /usr/include/cuda_runtime.h:83,
   ***                    from <command-line>:
   ***   /usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
   ***     138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
   ***         |  ^~~~~
   ***   CMake Error at cuda_test_generated_cuda_test.cu.o.cmake:216 (message):
   ***     Error generating
   ***     /ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build/CMakeFiles/cuda_test.dir//./cuda_test_generated_cuda_test.cu.o
   ***   
   ***   
   ***   make[2]: *** [CMakeFiles/cuda_test.dir/build.make:77:CMakeFiles/cuda_test.dir/cuda_test_generated_cuda_test.cu.o] 错误 1
   ***   make[2]: 离开目录“/ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build”
   ***   make[1]: *** [CMakeFiles/Makefile2:82:CMakeFiles/cuda_test.dir/all] 错误 2
   ***   make[1]: 离开目录“/ssd1/xyf/personalization/dlib/build/dlib/cuda_test_build”
   ***   make: *** [Makefile:91:all] 错误 2
   ***   
   ***   
-- *****************************************************************************************************************
-- Disabling CUDA support for dlib.  DLIB WILL NOT USE CUDA

Steps to Reproduce

Use the following commands:

git clone https://github.com/davisking/dlib.git
cd dlib
mkdir build
cd build
cmake .. -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1 

Anything else?

No response

TinyTinni commented 2 months ago

/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!

You use gcc 9.4.0, which is, according to the error message, not supported by this cuda version.

See also https://stackoverflow.com/questions/6622454/cuda-incompatible-with-my-gcc-version for a version compatibility table.

Either update cuda to at least 11 or downgrade gcc to 8.

dlib-issue-bot commented 1 month ago

Warning: this issue has been inactive for 35 days and will be automatically closed on 2024-10-29 if there is no further activity.

If you are waiting for a response but haven't received one it's possible your question is somehow inappropriate. E.g. it is off topic, you didn't follow the issue submission instructions, or your question is easily answerable by reading the FAQ, dlib's official compilation instructions, dlib's API documentation, or a Google search.

YoucanBaby commented 4 weeks ago

/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!

You use gcc 9.4.0, which is, according to the error message, not supported by this cuda version.

See also https://stackoverflow.com/questions/6622454/cuda-incompatible-with-my-gcc-version for a version compatibility table.

Either update cuda to at least 11 or downgrade gcc to 8.

Thanks a lot for your relpy. I fix this error by update CUDA to 12.4