Ask Your Question
0

Unable to compile OpenCV with CUDA9 and gcc6

asked 2018-04-19 05:11:01 -0500

yxchng gravatar image

My system: CUDA 9.0 cudnn 7.1 gcc6/g++6

Encounter the following error: ``` CMake Error at cuda_compile_generated_gpu_mat.cu.o.cmake:206 (message): Error generating /home/yxchng/git/release/opencv-3.3.1/build/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_gpu_mat.cu.o

```

Cmake command:

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/gcc-6 -DCMAKE_CXX_COMPILER=/usr/bin/g++-6 -DBUILD_opencv_python2=ON -DBUILD_opencv_python3=ON -DWITH_CUDA=YES -DWITH_CUBLAS=YES -DCUDA_GENERATION=Pascal -DWITH_IPP=OFF -DCMAKE_INSTALL_PREFIX=install -DWITH_GSTREAMER=OFF -DCUDA_NVCC_FLAGS="-ccbin /opt/cuda/bin/gcc-6" ..

edit retag flag offensive close merge delete

Comments

I have the same problem. I have compiled with gcc-6 because gcc-7 is not supported by CUDA 9.0. My error is:

opencv/modules/core/include/opencv2/core/cuda/vec_math.hpp(203): error: calling a constexpr __host__ function("abs") from a __device__ function("abs") is not allowed. The experimental flag '--expt-relaxed-constexpr' can be used to allow this.
Doctor Robot gravatar imageDoctor Robot ( 2018-05-02 04:25:44 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-05-02 08:33:39 -0500

A solution for me was to compile with gcc-5 for the CUDA part.

So I did:

sudo apt install gcc-5 g++-5
cd opencv
git co 3.4.1
cd build
rm -rf *
cmake \
-D BUILD_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D CMAKE_BUILD_TYPE=RELEASE \
-D WITH_CUDA=ON \
-D CUDA_GENERATION="Pascal" \
-D CUDA_HOST_COMPILER:FILEPATH=/usr/bin/gcc-5 ..
make

The important lines are the installation of both gcc and g++ version 5 and the flag CUDA_HOST_COMPILER:FILEPATH=/usr/bin/gcc-5.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-04-19 05:11:01 -0500

Seen: 1,589 times

Last updated: May 02 '18