Addition to the above comment by sarnold, I tried with the 5.4 kernel, and that seemed to compile ok. But it still fails for 5.11 installed on the same system, regardless of changing $KERNELS to $CURRENT_KERNEL. Here is some relevant output:
sudo apt install nvidia-340 # after installing and booting linux 5.4 https://paste.ubuntu.com/p/HqJjsQk7hN/
contents of /var/lib/dkms/nvidia-340/340.108/build/make.log https://paste.ubuntu.com/p/nGtrn67VBJ/
So to get it working on 20.04.3, I had to install the 5.4 kernel and uninstall the HWE (5.11) kernel.
Addition to the above comment by sarnold, I tried with the 5.4 kernel, and that seemed to compile ok. But it still fails for 5.11 installed on the same system, regardless of changing $KERNELS to $CURRENT_KERNEL. Here is some relevant output:
sudo apt install nvidia-340 # after installing and booting linux 5.4 /paste. ubuntu. com/p/HqJjsQk7h N/
https:/
contents of /var/lib/ dkms/nvidia- 340/340. 108/build/ make.log /paste. ubuntu. com/p/nGtrn67VB J/
https:/
So to get it working on 20.04.3, I had to install the 5.4 kernel and uninstall the HWE (5.11) kernel.