Assure that you have the latest Nvidia driver 465.27, which can be downloaded here.
A 2G /swapfile is too small. Let's increase it to 4G.
Note: Incorrect use of the rm and dd commands can cause data loss. Suggest copy/paste.
In the terminal...
sudo swapoff -a # turn off swap
sudo rm -i /swapfile # remove old /swapfile