- Install the latest/stable version of the nvidia driver. For eg, 12.2 in my case
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.161.08 Driver Version: 535.161.08 CUDA Version: 12.2 |
|-----------------------------------------+----------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+======================+======================|
| 0 Tesla T4 On | 00000000:37:00.0 Off | 0 |
| N/A 47C P8 16W / 70W | 2MiB / 15360MiB | 0% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
+---------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=======================================================================================|
| No running processes found |
+---------------------------------------------------------------------------------------+
- Download the second cuda version you need to install (11.8) from here. Select the OS and the runfile (local)

- chmod +x cuda_11.8.0_520.61.05_linux.run
- sudo ./cuda_11.8.0_520.61.05_linux.run
- [IMPO] When prompted deselect the driver. So that we have the original driver intact and not spend next 2hrs fixing it!!


select install

-
[IMPO] Select No for the symlink update

-
Now update the environment variables
- export PATH=/usr/local/cuda-11.8/bin:$PATH
- export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH
- use CUDA_HOME variable to switch between different version. E.g.
CUDA_HOME=/usr/local/cuda-11.8 python setup.py develop