I found this after a search.
I know it is for Ubuntu 20.04 and 21.04 but thought it might work. What do you think?
As ChanganAuto commented, the NVIDIA driver 340 isn't officially supported on the kernel that 21.04 uses, 5.11. (The error log for the installation I mentioned actually doesn't contain anything other than what I was shown when installing.)
However, I was able to find a way to work around the issue and use the driver anyway, by following the instructions at nvidia-legacy : Butterfly. Basically, you have to enter the following three commands:
*sudo add-apt-repository ppa:kelebek333/nvidia-legacy*
*sudo apt-get update*
*sudo apt-get install xorg-modulepath-fix*
After executing these three commands and reopening the Software Sources settings, the option to select the NVIDIA driver was showing once again. I selected it, and it's working fine now.
Just a word of warning, though: after doing this, I noticed that the options for Important and Recommended Updates were deselected, so my system wasn't updating anymore. I selected those again and that solved that.