Failure to cross-compile CUDA for NVIDIA Drive AGX

Hi all,

my ultimate goal is to enable our CMake-based build-system to cross-compile applications using CUDA as well as DriveWorks code. So I followed the available documentation (e.g. https://developer.nvidia.com/drive/learn/tutorial-xcompilation ).

I had success cross compiling a hello_world.cpp, so the basic setup seems to be cool.

I went on, compiling CUDA-based code. This failed, the reason is that all nvcc-generated object files are x86-64 and not aarch64.

So I set the CMakeVariables CMAKE_CUDA_HOST_COMPILER and CUDA_HOST_COMPILER, both point to the right position in the filesystem and are equivalent to CMAKE_CXX_COMPILER. But this had no effect on nvcc, it continues to use the x86-64 compiler.

How can I set in the CMakeLists.txt file the host compiler to use by nvcc?

I would expect that the nvcc host compiler is by default CMAKE_CXX_COMPILER, where is the right place to configure that?

Thanks for insights,
Michael.

I can now set the nvcc host compiler by explicitly adding the necessary nvcc command line flags like so:

In CMakeLists.txt inside the project definition.

set(CMAKE_CUDA_FLAGS “{CMAKE_CUDA_FLAGS} -ccbin {CMAKE_CXX_COMPILER}”)

Though I think there must be a better way.

Dear michael.binz,
As I understand, you want to use CUDA kernels along with Driveworks APIs.
We already have a DW sample with similar requirement (/usr/local/driveworks/samples/src/image/image_capture). Can you please check if you are able to cross compile this sample on your host following the cross compilation instructions in the documentation.
You can add your sample as sub folder in DW sample and make similar changes in CMakelists.txt to cross compile your sample. Please get back to us if you need any further clarifications.

I am facing a similar issue in cross compiling code for the Xavier using CMake 3.14.

Is it possible to specify the arch=compute and code=sm flags to be used by nvlink with target_link_options?

I could set those for the compiler by using target_compile_options.

Cheers,
Diego

Dear diegodbc,
Do you mean, you getting error when cross compiling image_capture sample?

Just to clarify, CMake 3.5 is prerequisite to cross compile the sample. Please check the “Getting Started” section in DW documentation\NVIDIA_DRIVE_SW_8.0_References\DRIVE_Software\DRIVE AV\baggage\dwx_devguide_getting_started.html)

Sorry I didn’t make myself clear.
I am not compiling the example code, but I am also dealing with cross compiling x86_64 to arm64.

I am working on a set of libraries targeting multiple versions of the Nvidia Jetson. I posted on the this thread because it is a related issue.

I will check somewhere on the Jetson forum.

Cheers