After you installed the first CUDA toolkit (preferably the latest stable version), and you want to install others beside it, due to some compatibililty issues for example, just do the following:
Download the standalone file installer, e.g. https://developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda_11.7.0_515.43.04_linux.run
chmod +x file_namesudo ./file_name
When prompted for the components, you MUST deselect the driver, better just keep the CUDA toolkit and deselect all others
When prompted to update the /usr/local/cuda symlink, DON’T accept
After installation is done, just run the following and you are good to go:
export PATH=/usr/local/cuda-11.7/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64:$LD_LIBRARY_PATH
Tested and working properly on Ubuntu 22.04 with A100 GPUs
Enjoy!
Source: https://medium.com/@peterjussi/multicuda-multiple-versions-of-cuda-on-one-machine-4b6ccda6faae