Score:2

What's the "collect2: error: ld returned 1 exit status" in cross compile

bw flag

When trying to cross compile the CUDNN samples:

cp -r /usr/src/cudnn_samples_v8/ $HOME
cd  $HOME/cudnn_samples_v8/mnistCUDNN
make clean
make TARGET_ARCH=aarch64 SBSA=1

Here is the error:

CUDA_VERSION is 12020
Linking agains cublasLt = true
CUDA VERSION: 12020
TARGET ARCH: aarch64
HOST_ARCH: x86_64
TARGET OS: linux
nvlink warning : Skipping incompatible '/usr/local/cuda/lib64/libcudadevrt.a' when searching for -lcudadevrt
nvlink warning : Skipping incompatible '/usr/local/cuda/lib64/libcudadevrt.a' when searching for -lcudadevrt
nvlink warning : Skipping incompatible '/usr/local/cuda/lib64/libcudadevrt.a' when searching for -lcudadevrt
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcublasLt.so when searching for -lcublasLt
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcublasLt.so when searching for -lcublasLt
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcublasLt.so when searching for -lcublasLt
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcudart.so when searching for -lcudart
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcudart.so when searching for -lcudart
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcudart.so when searching for -lcudart
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcublas.so when searching for -lcublas
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcublas.so when searching for -lcublas
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcublas.so when searching for -lcublas
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: cannot find -lfreeimage: No such file or directory
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: cannot find -lfreeimage: No such file or directory
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcudadevrt.a when searching for -lcudadevrt
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcudadevrt.a when searching for -lcudadevrt
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcudadevrt.a when searching for -lcudadevrt
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcudart_static.a when searching for -lcudart_static
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcudart_static.a when searching for -lcudart_static
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcudart_static.a when searching for -lcudart_static
collect2: error: ld returned 1 exit status
>>> WARNING - FreeImage is not set up correctly. Please ensure FreeImage is set up correctly. <<<
[@] /usr/local/cuda/bin/nvcc -I/usr/local/cuda/include -I/usr/local/cuda/include -IFreeImage/include -ccbin aarch64-linux-gnu-g++ -m64 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_53,code=sm_53 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_62,code=sm_62 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_72,code=sm_72 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_87,code=sm_87 -gencode arch=compute_90,code=sm_90 -gencode arch=compute_90,code=compute_90 -o fp16_dev.o -c fp16_dev.cu
[@] aarch64-linux-gnu-g++ -I/usr/local/cuda/include -I/usr/local/cuda/include -IFreeImage/include -o fp16_emu.o -c fp16_emu.cpp
[@] aarch64-linux-gnu-g++ -I/usr/local/cuda/include -I/usr/local/cuda/include -IFreeImage/include -o mnistCUDNN.o -c mnistCUDNN.cpp
[@] /usr/local/cuda/bin/nvcc -ccbin aarch64-linux-gnu-g++ -m64 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_53,code=sm_53 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_62,code=sm_62 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_72,code=sm_72 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_87,code=sm_87 -gencode arch=compute_90,code=sm_90 -gencode arch=compute_90,code=compute_90 -o mnistCUDNN fp16_dev.o fp16_emu.o mnistCUDNN.o -I/usr/local/cuda/include -I/usr/local/cuda/include -IFreeImage/include -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib64 -lcublasLt -LFreeImage/lib/linux/aarch64 -LFreeImage/lib/linux -lcudart -lcublas -lcudnn -lfreeimage -lstdc++ -lm

The libfreeimage3 libfreeimage-dev are already installed:

https://forums.developer.nvidia.com/t/freeimage-is-not-set-up-correctly-please-ensure-freeimae-is-set-up-correctly/66950/2

What's the "collect2: error: ld returned 1 exit status" in the above output? How to find the cause?

Score:3
jp flag

The GNU linker(ld) is a tool(one of many) invoked during the compilation process to create an executable from object files created/called in your project.

collect2 is the tool collecting/inspecting the linker's output.

collect2: error: ld returned 1 exit status

simply mean the above linking operation didn't succeed, but it's not the actual cause casing your compilation operation to fail, but rather a consequent result of previous errors and it's those errors that you need to mind ... For example:

cannot find -lfreeimage: No such file or directory

With further info in:

>>> WARNING - FreeImage is not set up correctly. Please ensure FreeImage is set up correctly. <<<

Notice: that libfreeimage availability on your system might not be the one and only cause for that error, but it could be needing some other related libraries like for example libcudnn(inspired partly by you tagging your question with nvidia) depending on your project.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.