/usr/bin/ld: skipping incompatible /usr/local/cuda-11.8/lib64/libcudnn.so when searching for -lcudnn
The undefined references might be because you are not linking to cuDNN. How did you install cuDNN and CUDA? For cuDNN I always download the Local Installer for Linux x86_64 (Tar) and extract to the CUDA directory.
If the errors are not related to this I would first move your python install (mv /home/mltrainer/anaconda3 /home/mltrainer/anaconda3_bak) re-source .bashrc if necessary and then try to build with CUDA without python to make sure the errors are not a result of libraries in your /home/mltrainer/anaconda3
directory.