Install CUDA in Ubuntu, problems and workarounds
After a whole night(mare) troubleshooting, finally I got Nvidia CUDA installed in my Ubuntu 18.04. here is how I get it done.
Follow the instruction list here and verify your system is all ready to go.Then execute
wget https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda_11.1.1_455.32.00_linux.run
Before moving to next step. you need to unload the original NVIDIA driver from kernel
$ sudo apt-get purge nvidia*
$ sudo apt-get autoremove
Then restart twice. you shall boot to a system without GPU driver installed. (pretty ugly and distorted UI) Next,run this to install CUDA
$ sudo sh cuda_11.1.1_455.32.00_linux.run
At this stage, you may want to check the cuda version you just installed. run this
$ nvidia-smi
Now, install Pytorch, since python 3.x in ubuntu will use pip3 instead of pip, update a bit of the pip script you copied from Pytorch get started page.
$ pip3 install torch==1.7.0+cu110 torchvision==0.8.1+cu110 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
Done, you are now have finished CUDA installation and should be ready to go ML.