Ld out of memory when compling cudnn sample

Running on Kubuntu 18.04 x64 with a 1080ti. I’m trying to install the latest version of cudnn (7.4.1). I have cuda 10 installed, no problem.

I’ve installed cudnn on other machines without any issues. I’ve tried both a manual install and a dpkg install. Whenever I try to compile something with cudnn, I get the following error:

/usr/bin/ld: out of memory allocating 281474976710656 bytes after a total of 835584 bytes
collect2: error: ld returned 1 exit status

e.g. from the install sample:

rm -rf *o
rm -rf mnistCUDNN

/usr/bin/ld: out of memory allocating 281474976710656 bytes after a total of 835584 bytes
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 -ccbin g++ -I/usr/local/cuda/include -IFreeImage/include -m64 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_53,code=sm_53 -gencode arch=compute_53,code=compute_53 -o fp16_dev.o -c fp16_dev.cu
[@] g++ -I/usr/local/cuda/include -IFreeImage/include -o fp16_emu.o -c fp16_emu.cpp
[@] g++ -I/usr/local/cuda/include -IFreeImage/include -o mnistCUDNN.o -c mnistCUDNN.cpp
[@] /usr/local/cuda/bin/nvcc -ccbin g++ -m64 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_53,code=sm_53 -gencode arch=compute_53,code=compute_53 -o mnistCUDNN fp16_dev.o fp16_emu.o mnistCUDNN.o -I/usr/local/cuda/include -IFreeImage/include -LFreeImage/lib/linux/x86_64 -LFreeImage/lib/linux -lcudart -lcublas -lcudnn -lfreeimage -lstdc++ -lm

Also not sure why it’s moaning about Freeimage, since it’s distributed in the folder and the lib exists (also installed via apt for sanity). The problem is ld. It’s not an out of memory error, ld is trying to allocate 2^48 bytes. I would guess this is a path problem, but the libraries definitely exist in places where nvcc can find them.

Is it a compatibility problem with 18.04? I can compile cuda code without any problems, it’s only when I add cudnn into the mix (e.g. I can build darknet with cuda enabled, but not with cudnn too).

I am having this sort of problem and I am running Ubuntu 22.04.1 LTS
I am building the https://developer.nvidia.com/opencl

verbose=1 make
make[1]: Entering directory '~/Projects/test/NVIDIA_GPU_Computing_SDK/OpenCL/common'
mkdir -p ../..//shared/lib/x86_64_linux
mkdir -p obj/Release
mkdir -p ../..//OpenCL//common//lib/x86_64_linux
ar qv ../..//OpenCL//common//lib/x86_64_linux/liboclUtil_x86_64.a obj/Release/oclUtils.cpp.o  
a - obj/Release/oclUtils.cpp.o
make[1]: Leaving directory '~/Projects/test/NVIDIA_GPU_Computing_SDK/OpenCL/common'
make[1]: Entering directory '~/Projects/test/NVIDIA_GPU_Computing_SDK/shared'
mkdir -p ..//shared/lib/x86_64_linux
mkdir -p obj/Release
mkdir -p ..//OpenCL//common//lib/x86_64_linux
ar qv ..//OpenCL//common//lib/x86_64_linux/libshrutil_x86_64.a obj/Release/cmd_arg_reader.cpp.o  
a - obj/Release/cmd_arg_reader.cpp.o
make[1]: Leaving directory '~/Projects/test/NVIDIA_GPU_Computing_SDK/shared'
make[1]: Entering directory '/home/exrhizo/Projects/test/NVIDIA_GPU_Computing_SDK/OpenCL/src/oclBlackScholes'
mkdir -p ../../..//shared/lib/x86_64_linux
mkdir -p obj/Release
mkdir -p ../../..//OpenCL//bin//x86_64_linux_Release
g++ -fPIC -m64 -o ../../..//OpenCL//bin//x86_64_linux_Release/oclBlackScholes obj/Release/main.cpp.o obj/Release/oclBlackScholes_gold.cpp.o obj/Release/oclBlackScholes_launcher.cpp.o  -L/usr/lib64/ -L/usr/local/cuda-12.0/lib64 -L../../..//OpenCL//common//lib/x86_64_linux -L../../..//shared/lib/x86_64_linux -L../../..//shared//lib/x86_64_linux   -lOpenCL  -L/usr/lib64/ -L/usr/local/cuda-12.0/lib64 -L../../..//OpenCL//common//lib/x86_64_linux -L../../..//shared/lib/x86_64_linux -L../../..//shared//lib/x86_64_linux    -loclUtil_x86_64 -lshrutil_x86_64 -lvulkan -lglfw
/usr/bin/ld: warning: ../../..//shared/lib/x86_64_linux/libvulkan.so has a section extending past end of file

/usr/bin/ld: out of memory allocating 1152477164470272 bytes after a total of 987136 bytes
collect2: error: ld returned 1 exit status
make[1]: *** [../../common/common_opencl.mk:247: ../../..//OpenCL//bin//x86_64_linux_Release/oclBlackScholes] Error 1
make[1]: Leaving directory '~/Projects/test/NVIDIA_GPU_Computing_SDK/OpenCL/src/oclBlackScholes'
make: *** [Makefile:47: src/oclBlackScholes/Makefile.ph_build] Error 2