Hi,
I try to cross compile Cuda code for Jetson Xavier.
During the compilation I encounter several problems and currently I am stuck at the
" simple test program. " compilation.
Thats because the cmake tries to linking the code by using aarch64 gcc instad of nvcc linker,
as you can see in the error log below (Code number 3),what cause to the AARCH64 cuda libs to be missing.
In addition I try to config the linker flags which seems to be working (code number 2) but I still dose not figure out how to config the linker to be nvcc.
If somenone have working cmake for cuda Cross compile with arm , have a guide how to do it or can help me to figure out how to fix my cmake (code number 1) I will very appreciate it.
In addition I add my Cmake (Code number 1) in
CMake file :
cmake_minimum_required(VERSION 3.14)
# find packages
# CUDA
project (TestMultiply) #LANGUAGES CXX CUDA)
#set(CMAKE_C_LINK_EXECUTABLE "nvcc -m64 -ccbin aarch64-linux-gnu-g++")
set(CMAKE_C_COMPILER nvcc)
set(CMAKE_CXX_COMPILER nvcc)
set(CMAKE_CXX_LINK_FLAGS "-m64 -ccbin aarch64-linux-gnu-g++")
set(CUDA_HOST_COMPILATION_CPP "nvcc")
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_SYSROOT $ENV{SYSROOT})
MESSAGE(STATUS "CUDA_TOOLKIT_ROOT_DIR:"${CUDA_TOOLKIT_ROOT_DIR})
set(CMAKE_CUDA_FLAGS "-m64 -ccbin aarch64-linux-gnu-g++ -gencode arch=compute_61,code=sm_61 -gencode arch=compute_72,code=sm_72 -gencode arch=compute_75,code=sm_75 -use_fast_math -O3 -std=c++11")
set (CUDAHOSTCXX "nvcc -m64 -ccbin aarch64-linux-gnu-g++")
set (CMAKE_EXE_LINKER_FLAGS "-m64 -ccbin aarch64-linux-gnu-g++")
set (CUDAHOSTCC nvcc)
#set(CMAKE_CUDA_COMPILER "/usr/local/cuda-10.0/bin/nvcc")# -m64 -ccbin aarch64-linux-gnu-g++")
#set(CUDA_HOST_COMPILER "-m64 -ccbin aarch64-linux-gnu-g++")
set(CUDA_HOST_COMPILER "/usr/local/cuda-10.0/bin/nvcc")
#set(CMAKE_CUDA_HOST_COMPILER "/usr/local/cuda-10.0/bin/nvcc")
#set(CMAKE_CUDA_HOST_COMPILER "/usr/local/cuda-10.0/bin/nvcc" CACHE FILEPATH "Host compiler to be used by nvcc")
#FIND_PACKAGE(CUDA)
set(_cuda_target_cpu_arch_initial "AARCH64")
enable_language(CUDA)
set(CUDA_HOST_COMPILATION_CPP ON)
set (CUDA_PROPAGATE_HOST_FLAGS OFF)
set(CMAKE_VERBOSE_MAKEFILE OFF)
set(C++11 ON)
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
INCLUDE(FindCUDA)
add_executable(TestMultiply matrixMul.cu)
#set(CMAKE_CUDA_HOST_LINK_LAUNCHER "nvcc")
INCLUDE_DIRECTORIES(
/usr/local/cuda/include
/usr/local/cuda-10.0/samples/common/inc
)
TARGET_LINK_LIBRARIES (TestMultiply -- a##
${FindCUDA}
)
Error log:
CMake Warning (dev) at CMakeLists.txt:23:
Syntax Warning in cmake code at column 40
Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.
-- CUDA_TOOLKIT_ROOT_DIR:
-- The CUDA compiler identification is NVIDIA 10.0.326
-- LINK_LIBRARIES:
-- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc
-- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc -- broken
CMake Error at /usr/share/cmake-3.15/Modules/CMakeTestCUDACompiler.cmake:46 (message):
The CUDA compiler
"/usr/local/cuda/bin/nvcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /users/Yehonatans/work/CmakeCudaAARCH/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_4b14f/fast && /usr/bin/make -f CMakeFiles/cmTC_4b14f.dir/build.make CMakeFiles/cmTC_4b14f.dir/build
make[1]: Entering directory '/users/Yehonatans/work/CmakeCudaAARCH/CMakeFiles/CMakeTmp'
Building CUDA object CMakeFiles/cmTC_4b14f.dir/main.cu.o
/usr/local/cuda/bin/nvcc -m64 -ccbin aarch64-linux-gnu-g++ -gencode arch=compute_61,code=sm_61 -gencode arch=compute_72,code=sm_72 -gencode arch=compute_75,code=sm_75 -use_fast_math -O3 -std=c++11 -x cu -c /users/Yehonatans/work/CmakeCudaAARCH/CMakeFiles/CMakeTmp/main.cu -o CMakeFiles/cmTC_4b14f.dir/main.cu.o
Linking CUDA executable cmTC_4b14f
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_4b14f.dir/link.txt --verbose=1
/usr/bin/aarch64-linux-gnu-g++ -m64 -ccbin aarch64-linux-gnu-g++ CMakeFiles/cmTC_4b14f.dir/main.cu.o -o cmTC_4b14f
aarch64-linux-gnu-g++: error: aarch64-linux-gnu-g++: No such file or directory
aarch64-linux-gnu-g++: error: unrecognized command line option ‘-m64’
aarch64-linux-gnu-g++: error: unrecognized command line option ‘-ccbin’
CMakeFiles/cmTC_4b14f.dir/build.make:86: recipe for target 'cmTC_4b14f' failed
make[1]: *** [cmTC_4b14f] Error 1
make[1]: Leaving directory '/users/Yehonatans/work/CmakeCudaAARCH/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_4b14f/fast' failed
make: *** [cmTC_4b14f/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:38 (enable_language)
-- Configuring incomplete, errors occurred!
Error log when CMAKE_EXE_LINKER_FLAGS is disable
CMake Warning (dev) at CMakeLists.txt:23:
Syntax Warning in cmake code at column 40
Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.
-- CUDA_TOOLKIT_ROOT_DIR:
-- The CUDA compiler identification is NVIDIA 10.0.326
-- LINK_LIBRARIES:
-- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc
-- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc -- broken
CMake Error at /usr/share/cmake-3.15/Modules/CMakeTestCUDACompiler.cmake:46 (message):
The CUDA compiler
"/usr/local/cuda/bin/nvcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /users/Yehonatans/work/CmakeCudaAARCH/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_5782d/fast && /usr/bin/make -f CMakeFiles/cmTC_5782d.dir/build.make CMakeFiles/cmTC_5782d.dir/build
make[1]: Entering directory '/users/Yehonatans/work/CmakeCudaAARCH/CMakeFiles/CMakeTmp'
Building CUDA object CMakeFiles/cmTC_5782d.dir/main.cu.o
/usr/local/cuda/bin/nvcc -m64 -ccbin aarch64-linux-gnu-g++ -gencode arch=compute_61,code=sm_61 -gencode arch=compute_72,code=sm_72 -gencode arch=compute_75,code=sm_75 -use_fast_math -O3 -std=c++11 -x cu -c /users/Yehonatans/work/CmakeCudaAARCH/CMakeFiles/CMakeTmp/main.cu -o CMakeFiles/cmTC_5782d.dir/main.cu.o
Linking CUDA executable cmTC_5782d
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_5782d.dir/link.txt --verbose=1
/usr/bin/aarch64-linux-gnu-g++ CMakeFiles/cmTC_5782d.dir/main.cu.o -o cmTC_5782d
CMakeFiles/cmTC_5782d.dir/main.cu.o: In function `__cudaUnregisterBinaryUtil()':
tmpxft_00000184_00000000-5_main.compute_75.cudafe1.cpp:(.text+0x8): undefined reference to `__cudaUnregisterFatBinary'
CMakeFiles/cmTC_5782d.dir/main.cu.o: In function `__sti____cudaRegisterAll()':
tmpxft_00000184_00000000-5_main.compute_75.cudafe1.cpp:(.text.startup+0x18): undefined reference to `__cudaRegisterFatBinary'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_5782d.dir/build.make:86: recipe for target 'cmTC_5782d' failed
make[1]: *** [cmTC_5782d] Error 1
make[1]: Leaving directory '/users/Yehonatans/work/CmakeCudaAARCH/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_5782d/fast' failed
make: *** [cmTC_5782d/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:38 (enable_language)
-- Configuring incomplete, errors occurred!