Installing CUDA is a very torturous thing to do, so here are the steps I took to install CUDA successful (at least enough for Darknet YOLO Object Detection).
Resources
Linux - Ubuntu 16.04 (min 30Gb space)
CUDA 9.0 (maybe 9.3 too?)
Why so difficult?
Installing CUDA is painful because following the instruction given in the website itself will procure an error about X server. Googling on how to disable X server is worthy of another page by itself, and even after following all the instructions online (at least to the best of my ability) I still couldn't disable X server for the installation of CUDA 9.0. Thus, after much research(googling) and tears. I have come out with a method of installing CUDA without needing to disable X server
BEFORE YOU CONTINUE
Checklist: (if you could not tick any close this page and abandond all hope)
Do you have a Nvidia Graphics card?
Is your card CUDA capable?
Do you wish to suffer from frustration and hair lost(from pulling it)?
If your answer to above is all yes, you may proceed...
Flow of installation
Normally, if you just google CUDA 9.0 toolkit, you will come across a website by Nvidia providing
CUDA 9.0 Toolkit download. After providing info of your operating system and versions, you can
finally
download the file and realised that you cannot install it. The file that is provided by Nvidia
is
a bundle of:
1. Nvidia card driver
2. CUDA toolkit itself
3. Sample CUDA
files
The installation of the card driver is what cause the X server error, so if you can install the
card
driver separately..... yeah (PROBLEM = SOLVE). If you know what to do after this, then good for
you, if
not, follow along what I did
WHAT YOU WILL NEED
CUDA 9.0 toolkit from Nvidia (get the .run file) (just google it)
thats all you need to download separately, anything else could be done from the linux terminal itself
Installing: Nvidia Card Driver
Open up terminal and add the official Nvidia PPA to Ubuntu
Next, install nvidia driver
sudo apt install nvidia-387
For NV4x and G7x GPUs use `nvidia-304` (304.137)
Reboot your system after driver installation
Next, verify if driver is properly installed
If verification is correct, proceed
Installing: CUDA Toolkit 9.0 and Sample
Open Terminal in the same location where you install your CUDA .run file(the one that you install above)
install the .run file
change the code above accordingly
An EULA will appear, scroll to the bottom of it to continue
Accept the EULA
READ THE INSTRUCTION AND DO NOT INSTALL THE NVIDIA DRIVER (already installed above)
Say YES('y') to everything else
After installing, run the following
sudo ldconfig
I don't know what the above does, but just do it...
Test CUDA Installation
Make the sample file
sudo make
Test it!
./deviceQuery
If everything goes well, then CONGRATULATION!!!! YOU DID IT!!!
Setting CUDA up
Next, will just be some path thingy to configure CUDA properly
And the next is Operating System sensitive, so for 64-bit run
{LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
For 32-bit
{LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
And you are done. xD
Troubleshooting
It will be sad if you are reading this, but if you are still determined to install CUDA, here are the website that I used when installing mine
https://gist.github.com/zhanwenchen/e520767a409325d9961072f666815bb8
https://websiteforstudents.com/install-proprietary-nvidia-gpu-drivers-on-ubuntu-16-04-17-10-18-04/
https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#pre-installation-actions
If all else fails, just GoOglE it ;)