Mam problemy z kompilowaniem mojego kodu CUDA z CMake. Używam CUDA 7 oraz informacje o wersji z nvcc jest następujący:Problem z kompilacją CUDA z CMake
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2014 NVIDIA Corporation
Built on Tue_Dec__9_18:10:46_CST_2014
Cuda compilation tools, release 7.0, V7.0.17
Mój plik CUpewnij używa makra find_cuda następująco:
find_package(CUDA)
if(CUDA_FOUND)
list(APPEND CUDA_NVCC_FLAGS "-arch=sm_20;--compiler-options;-std=c++11;-O2;-DVERBOSE")
endif(CUDA_FOUND)
dodałem std = C++ 11 flag kompilatora po wielu postach sugerowało, że było to potrzebne. Jednak otrzymuję dokładnie te same błędy z tą flagą lub bez niej.
Dodałem także następujące elementy, aby usunąć obsługę C++ 11 z flag kompilacji nvcc, ale to też niczego nie zmienia.
if(CMAKE_COMPILER_IS_GNUCC)
string(REPLACE "-std=c++11" "" CUDA_HOST_FLAGS "${CUDA_HOST_FLAGS}")
string(REPLACE "-std=c++0x" "" CUDA_HOST_FLAGS "${CUDA_HOST_FLAGS}")
endif(CMAKE_COMPILER_IS_GNUCC)
Błędy dostaję są następujące:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h(432): error: identifier "nullptr" is undefined
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h(432): error: expected
a ";"
/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++config.h(190): error:
expected a ";"
/usr/include/c++/4.8/exception(63): error: expected a ";"
/usr/include/c++/4.8/exception(68): error: expected a ";"
/usr/include/c++/4.8/exception(76): error: expected a ";"
/usr/include/c++/4.8/exception(83): error: expected a ";"
/usr/include/c++/4.8/exception(93): error: expected a "{"
/usr/include/c++/4.8/bits/exception_ptr.h(64): error: function
"std::current_exception" returns incomplete type
"std::__exception_ptr::exception_ptr"
Używam gcc 4.8, ale dostać te same błędy z 4,7 jak dobrze. Jestem na cmake 2.8.12.2.
Kompilacja z CUpewnij gadatliwym daje następujące flagi dla nvcc kompilacji:
/usr/local/cuda-7.0/bin/nvcc /home/xargon/Dropbox/code/gpu-mosaicing
/src/gpu/kernels/bgra_2_gray.cu -c -o /home/xargon/code/mosaicing_bin
/gpu/kernels/CMakeFiles/kernels.dir//./kernels_generated_bgra_2_gray.cu.o
-ccbin /usr/bin/cc -m64 -DUSE_CUDA -DUSE_OPENCV -DUSE_QT -Xcompiler
,\"-std=c++11\",\"-O3\",\"-DNDEBUG\" -arch=sm_20 --compiler-options
-std=c++11 -O2 -DVERBOSE -DNVCC -I/usr/local/cuda-7.0/include -I/usr/local
/include/opencv -I/usr/local/include -I/home/xargon/Dropbox/code/gpu-
mosaicing/src/cpu/gui/qt -I/usr/include -I/home/xargon/Dropbox/code/gpu-
mosaicing/src/cpu/core -I/home/xargon/Dropbox/code/gpu-mosaicing/src/cpu
/datasources -I/home/xargon/Dropbox/code/gpu-mosaicing/src/gpu
/intraoperability -I/home/xargon/Dropbox/code/gpu-mosaicing/src/utils
-I/usr/local/cuda-7.0/include
Tak, mam następujące: /bgra_2_gray .cu -c -o /home/xargon/code/mosaicing_bin/gpu/kernels/CMakeFiles/kernels.dir//./kernels_generated_bgra_2_gray.cu.o -ccbin/usr/bin/cc -m64 -DUSE_CUDA -DUSE_OPENCV -DUSE_QT -Xcompiler, \ "- std = C++ 11 \", \ "- O3 \", \ "- DNDEBUG \" -arch = sm_20 - -compiler-options -std = C++ 11 -O2-DVERBOSE -DNVCC – Luca
Te rzeczy w Xcompiler są zwyczajnie głupie. Przekazujesz -std = C++ 11, więc to nie jest problem. – usr1234567
Ok, więc problem polegał na tym, że faktycznie usunięto flagę std = C++ 11. Tak więc musiałem ustawić CUDA_PROPAGATE_HOST_FLAGS na OFF. Jednak myślałem, że Cuda 7 obsługuje funkcje C++ 11 i zastanawiałem się, co się dzieje. – Luca