Remove all old cuda versions

I am running RHEL 8 and ubuntu LTS on various machines. I have installed cuda and nvidia drivers from the repository as shown on the cuda installation page, Everything works great. The problem I have is that after install cuda, sudo dnf -y install cuda, each new version is installed and then I end up with a lot of cuda versions around. Is there an easy way to uninstall all but the latest cuda version? Currently on my system I have 11.4, 11.5, and 11.6 installed. Similarly I end up with many different versions of Nsight Compute and Nsight systems. I would appreciate a way to optionally only keep around the latest versions, or at least a straightforward way to uninstall all previous versions.