nvcc cross compile broken

cmake:
if(WITH_CUDA)
if(CMAKE_VERSION VERSION_GREATER 3.10)
set(CMAKE_CUDA_COMPILER $ENV{HOME}/opt/toolchains/cuda/bin/nvcc)
# set(CMAKE_CUDA_COMPILER /usr/local/cuda/bin/nvcc)
enable_language(CUDA)
endif()
message(STATUS “use cuda to compile”)
add_definitions(-DWITH_CUDA)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} “-m64 -ccbin”)
set(CUDA_NVCC_FLGAS_DEBUG “-g -G -Og”)
set(CUDA_NVCC_FLGAS_RELEASE “-Ofast -lineinfo”)
endif()

compile error:
use toolchains under /home/ouzh/opt/toolchains
QNX_HOST=/home/ouzh/opt/toolchains/qnx700/host/linux/x86_64
QNX_TARGET=/home/ouzh/opt/toolchains/qnx700/target/qnx7
MAKEFLAGS=-I/home/ouzh/opt/toolchains/qnx700/target/qnx7/usr/include
Find onnx2trt_rcnn
– The C compiler identification is GNU 5.4.0
– The CXX compiler identification is GNU 5.4.0
– Check for working C compiler: /home/ouzh/opt/toolchains/qnx700/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-gcc
– Check for working C compiler: /home/ouzh/opt/toolchains/qnx700/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-gcc – 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: /home/ouzh/opt/toolchains/qnx700/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-g++
– Check for working CXX compiler: /home/ouzh/opt/toolchains/qnx700/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-g++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– QNX HOST:/home/ouzh/opt/toolchains/qnx700/host/linux/x86_64
– USER HOME DIR:/home/ouzh
– compile type:Release
– The CUDA compiler identification is unknown
– Check for working CUDA compiler: /home/ouzh/opt/toolchains/cuda/bin/nvcc
– Check for working CUDA compiler: /home/ouzh/opt/toolchains/cuda/bin/nvcc – broken
CMake Error at /usr/local/share/cmake-3.15/Modules/CMakeTestCUDACompiler.cmake:46 (message):
The CUDA compiler

"/home/ouzh/opt/toolchains/cuda/bin/nvcc"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /home/ouzh/opt/xplorer/xpilot/modules/perception/tools/onnx2trt_rcnn/rain_detection/build/CMakeFiles/CMakeTmp

Run Build Command(s):/home/ouzh/opt/toolchains/qnx700/host/linux/x86_64/usr/bin/make cmTC_f3ed8/fast && /home/ouzh/opt/toolchains/qnx700/host/linux/x86_64/usr/bin/make -f CMakeFiles/cmTC_f3ed8.dir/build.make CMakeFiles/cmTC_f3ed8.dir/build
make[1]: Entering directory '/home/ouzh/Documents/rain_detection/build/CMakeFiles/CMakeTmp'
Building CUDA object CMakeFiles/cmTC_f3ed8.dir/main.cu.o
/home/ouzh/opt/toolchains/cuda/bin/nvcc     -x cu -c /home/ouzh/opt/xplorer/xpilot/modules/perception/tools/onnx2trt_rcnn/rain_detection/build/CMakeFiles/CMakeTmp/main.cu -o CMakeFiles/cmTC_f3ed8.dir/main.cu.o
cc1plus: fatal error: cuda_runtime.h: 没有那个文件或目录
compilation terminated.
CMakeFiles/cmTC_f3ed8.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_f3ed8.dir/main.cu.o' failed
make[1]: *** [CMakeFiles/cmTC_f3ed8.dir/main.cu.o] Error 1
make[1]: Leaving directory '/home/ouzh/Documents/rain_detection/build/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_f3ed8/fast' failed
make: *** [cmTC_f3ed8/fast] Error 2

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:53 (enable_language)

– Configuring incomplete, errors occurred!
See also “/home/ouzh/opt/xplorer/xpilot/modules/perception/tools/onnx2trt_rcnn/rain_detection/build/CMakeFiles/CMakeOutput.log”.
See also “/home/ouzh/opt/xplorer/xpilot/modules/perception/tools/onnx2trt_rcnn/rain_detection/build/CMakeFiles/CMakeError.log”.

Hi,

Please noticed you will need to install the CUDA toolkit from sdkmanager, which includes cross compiling tool.
Did you setup your CUDA toolkit with sdkmanager?

Thanks.

the cross compiling tool is already provided,but I can’t use nvcc with cmake,is there some problems with toolchains?

Hi,

Sorry for the late update.

Based on the error log in comment#1.
This is a missing file error rather than the toolchain issue.

cc1plus: fatal error: cuda_runtime.h: 没有那个文件或目录

Could you double check the include/link directory again?
Thanks.

but I have added the cuda_runtime.h path to the include_directories in CMakeLists.txt

Hi,

Could you add this to your CMakeList file and try it again?

find_package(CUDA)

Thanks.

Hi 18301295852,

We haven’t heard back from you in a couple weeks, so marking this topic closed.
Please open a new forum issue when you are ready and we’ll pick it up there.