Notes: Yes, there is the possibility to install it via apt-get install cuda. I strongly suggest not to use it, as it changes the paths and makes the installation of other tools more difficult.
I tried to install many times via the .run file, but some error always crept in and I either ran into a login loop or completely lost the display. Therefore I would recommend to use the .deb file and not fiddle with the display manager.
To install the Nvidia driver you can do the following:
In Ubuntu Search your Computer menu at the left top corner search Additional Drivers (You might also do System Settings > Software and Updates > Additional Drivers)
In the menu that appears select one of the Nvidia Drivers and click Apply Changes. (This step uses the internet. If it still fails then your proxy server might be blocking the download)
Reboot your system.
Open a terminal window and type nvidia-smi. If your driver has been installed correctly you should see something like:
+------------------------------------------------------+
| NVIDIA-SMI 3.295.41 Driver Version: 295.41 |
|-------------------------------+----------------------+----------------------+
| Nb. Name | Bus Id Disp. | Volatile ECC SB / DB |
| Fan Temp Power Usage /Cap | Memory Usage | GPU Util. Compute M. |
|===============================+======================+======================|
| 0. Tesla C2050 | 0000:05:00.0 On | 0 0 |
| 30% 62 C P0 N/A / N/A | 3% 70MB / 2687MB | 44% Default |
|-------------------------------+----------------------+----------------------|
| Compute processes: GPU Memory |
| GPU PID Process name Usage |
|=============================================================================|
| 0. 7336 ./align 61MB |
+-----------------------------------------------------------------------------+
You can easily install CUDA according to the previous link now. In brief:
sudo apt-get install linux-headers-$(uname -r)
Download a toolkit from here and then install the .deb file (replace name accordingly)
I also tried difference approaches so as to install Cuda 8.0 in Ubuntu 16.04. Finally, these are the steps which do the trick. I followed this tutorial and updated corrected steps as follows.
Update system PATH in .bashrc which can be found in the home directory. Please note if you install those thing into difference location, please update path according to that.
Edit the bumblebee config file so bumblebee knows we are using the NVIDIA driver. Please update the path according to your system. Here is reference view which will help.
Edit the xorg.conf.nvidia file so it knows the PCI address(01:00.0 for me) of your video card. Update PIC address as below under section "ServerLayout"
This is a looooong answer as i was screwing my laptop several times while writing it. However, I rather to keep it long since it maybe useful for other people too ;)
The best part of my answer starts from Edited-Updated
Sooooo, I read all the answers here and other places, I dont know why, but each of them cause me an issue :(
After 4 days, re installing Linux back and forth here is the way that worked for me.
Before going to the main procedure i want to mention an alternative method.
alternative method if you are using a laptop:
So you can switch between your nvidia and your intel gpu on your laptop by using
sudo prime-select intel
sudo prime-select nvidia
In other words, you can switch to intel and install nvidia and the switch back to intel for normal usages and whenever you want to use deep learning switch to nvidia one.
Anyway,
let me talk about the main method that finally works for me (info here are mainly grabbed from Link):
Deleting and purging all existing nvidia/cuda stuff:
Now, there would be a possibility that you cannot log in and you get stuck in the loop...
No worries, I faced that more than 50 times...
press ctr+alt+F2
type your username and password
now type these:
sudo service lightdm stop
Optional, some people also need to type this, honestly idk what is the use of it: sudo init 3
sudo nano /etc/modprobe.d/blacklist-nouveau.conf
add
blacklist nouveau
options nouveau modeset=0
to it and save it and exit.
Then type:
sudo update-initramfs -u
go to the file that you have cuda .run file there and type:
sudo sh cuda_8.0_linux.run --override
sudo service lightdm start
sudo reboot
Sooo, if you are lucky, you should be able to login now. As you may guess, i was not a lucky one, and I still could not f**** login.
So i had to press ctr+Alt+F2 again and do the following:
sudo ubuntu-drivers autoinstall
sudo reboot
Now i could login finally.
Now it is the time to set the paths and check the installations.
export PATH=$PATH:/usr/local/cuda-8.0/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64
# Added by me on 2013/06/24
PATH=~/bin:$PATH
export PATH
Save and exit gedit.
Type:
sudo ldconfig /usr/local/cuda-8.0/lib64
A question for the people who knows more than me:
So everything sounds like working but when I shutdown/reboot my system for a few seconds it shows
So everything sounds like working but when I shutdown/reboot my system for a few seconds it shows “Failed to start Load Kernel Modules” I tryied this post but it is not helping, please let me know if you know how to fix it.
----------------
Edited-Updated
Guess what, I screwed again.
But this time I came with a much easier solusion. and here is the main point: Sometimes we need to say NO
Here is what works really good for me. after you purge and remove everything and sudo reboot do this:
sudo ubuntu-drivers autoinstall
sudo reboot
press ctr+alt+F2
type your username and password
now type these:
sudo service lightdm stop
sudo sh cuda_8.0_linux.run
IMPORTANT: during the installation, the first question asks for reinstalling the driver again, SAY NO to this mother f**** question
Say yes to the rest of them though :D
after finishing.
I got it to work after reading several posts:
I had an ATI card in the computer already which turned out to be very useful. I installed GTX 1070 along side of the ATI and started installing Kubuntu 16.04. Only the display connected to the ATI card had image initially, which allowed me to install the driver NVIDIA-Linux-x86_64-367.27.run downloaded from the vendor's website. To install CUDA, I downloaded the cuda_7.5.18_linux.run file. I installed the cuda toolkit by using two switches:
cuda_7.5.18_linux.run --silent --toolkit
The cuda samples can also be installed from the .run file. One issue was cuda does not like gcc5. So I did sudo apt-get install gcc-4.8 and then changed the default gcc to this version by:
My environment: Dual boot Windows 10 and Ubuntu 16.04 LTS.
Posting some major learnings here. Please see the blog post for detailed instructions (just to avoid duplication)
Disable Secure Boot at UEFI Firmware setting (do this in BIOS mode / restart from Windows advanced startup). (I did try for ages hoping I could get it working with Secure Boot enabled. No luck Secure Boot stopped the Nvidia driver from installing properly on Ubuntu. Disabling Secure Boot turns out to be the only working solution for me - if you are able to get Nvidia driver installed without having to disable Secure Boot, do let me know)
(my opinion) Use the Linux .deb (package manager) installation (for simplicity.). Download the .deb file in a browser. Install from terminal command line.
(my opinion) Don't use runfile installation (too complicated).
sudo apt-get install nvidia-cuda-toolkit OR 1'. the installation instructions here
You need to select from Software&Updates/Additional Drivers the nvidia driver (375, in my context)
Follow the blue screen when you restart and only from there disable secure boot by inputting your password set during nvidia driver install. (any secure boot disabling through the BIOS did not work for me).
A generally preferred method is to install SW is via deb files when available as they provide a more robust way to handle dependencies and a more reliable method for removing SW. The CUDA 8.0 release-candidate was available for 16.04 (in the dev zone) that way and now the CUDA 8.0 for Ubuntu 16.04 is available via deb files (local) and (network) :https://developer.nvidia.com/cuda-downloads
Just a kind reminder, Ubuntu 16.04 might not install cuda at the assumed location /usr/local/cuda-8.0.61. Hence export PATH=/usr/local/cuda-8.0.61/bin${PATH:+:${PATH}} may not work.
It turned out that Ubuntu installed cuda in /usr/local/cuda-8.0 instead of the assumed location /usr/local/cuda-8.0.61. Hence I changed export PATH=/usr/local/cuda-8.0.61/bin${PATH:+:${PATH}} into export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}} and I successfully installed cuda.
Install CUDA for Ubuntu
There is an Linux installation guide. However, it is basically only these steps:
md5sum cuda_7.5.18_linux.run
. Only continue if it is correct.sudo apt-get purge nvidia-cuda*
- if you want to install the drivers too, thensudo apt-get purge nvidia-*
.)sudo service lightdm stop
/etc/modprobe.d/blacklist-nouveau.conf
with the following contents:sudo update-initramfs -u
sudo sh cuda_7.5.18_linux.run --override
. Make sure that you sayy
for the symbolic link.sudo service lightdm start
See also: NVIDIA CUDA with Ubuntu 16.04 beta on a laptop (if you just cannot wait)
Notes: Yes, there is the possibility to install it via
apt-get install cuda
. I strongly suggest not to use it, as it changes the paths and makes the installation of other tools more difficult.You might also be interested in How can I install CuDNN on Ubuntu 16.04?.
*: Don't install the display drivers with this script. They are old. Download the latest ones from http://www.nvidia.com/Download/index.aspx
Verify CUDA installation
The following command shows the current CUDA version (last line):
The following command shows your driver version and how much GPU memory you have:
See also: Verify CuDNN installation
Help! The new driver does not work!
Don't panic. Even if you can't see anything on your computer, the following steps should get you back to the state before:
mount -o remount,rw /
(-
is?
and/
is-
in the american layout)sh cuda_7.5.18_linux.run --uninstall
sudo apt-get install nvidia-361 nvidia-common nvidia-prime nvidia-settings
Graphics drivers
Installing the graphics drivers is a bit tricky. This has to be done without graphics support.
dpkg -l | grep -i nvidia
sudo apt-get remove --purge nvidia-WHATEVER
sudo service lightdm stop
reboot
your pc / blacklist the nouveau driver (German tutorial)I tried to install many times via the .run file, but some error always crept in and I either ran into a login loop or completely lost the display. Therefore I would recommend to use the .deb file and not fiddle with the display manager.
NVIDIA CUDA Installation Guide for Linux is an excellent link that lists the complete details.Make sure you follow each step as it is given .
To install the Nvidia driver you can do the following:
In Ubuntu Search your Computer menu at the left top corner search Additional Drivers (You might also do System Settings > Software and Updates > Additional Drivers)
In the menu that appears select one of the Nvidia Drivers and click Apply Changes. (This step uses the internet. If it still fails then your proxy server might be blocking the download)
Reboot your system.
Open a terminal window and type
nvidia-smi
. If your driver has been installed correctly you should see something like:You can easily install CUDA according to the previous link now. In brief:
Download a toolkit from here and then install the
.deb
file (replace name accordingly)then run:
I also tried difference approaches so as to install Cuda 8.0 in Ubuntu 16.04. Finally, these are the steps which do the trick. I followed this tutorial and updated corrected steps as follows.
Update the system
Download VirtualGL and install it. To install
Download and install CUDA 8.0 and install it. I suggest to do it vs through the internet. As like this,
Install required dependencies.
Update system PATH in .bashrc which can be found in the home directory. Please note if you install those thing into difference location, please update path according to that.
Install bumblebee-nvidia and primus.
Edit the bumblebee config file so bumblebee knows we are using the NVIDIA driver. Please update the path according to your system. Here is reference view which will help.
Add:
Run the following and record the PCI address of your video card.
Edit the xorg.conf.nvidia file so it knows the PCI address(01:00.0 for me) of your video card. Update PIC address as below under section "ServerLayout"
Add:
Reboot the system and have a fun with running some sample codes.
This is a looooong answer as i was screwing my laptop several times while writing it. However, I rather to keep it long since it maybe useful for other people too ;) The best part of my answer starts from Edited-Updated
Sooooo, I read all the answers here and other places, I dont know why, but each of them cause me an issue :(
After 4 days, re installing Linux back and forth here is the way that worked for me.
Before going to the main procedure i want to mention an alternative method.
alternative method if you are using a laptop:
So you can switch between your nvidia and your intel gpu on your laptop by using
In other words, you can switch to intel and install nvidia and the switch back to intel for normal usages and whenever you want to use deep learning switch to nvidia one.
Anyway,
let me talk about the main method that finally works for me (info here are mainly grabbed from Link):
Deleting and purging all existing nvidia/cuda stuff:
Then, we just update everything:
Now, there would be a possibility that you cannot log in and you get stuck in the loop...
No worries, I faced that more than 50 times...
press
ctr+alt+F2
type your username and passwordnow type these:
Optional, some people also need to type this, honestly idk what is the use of it:
sudo init 3
add
to it and save it and exit.
Then type:
go to the file that you have cuda .run file there and type:
Sooo, if you are lucky, you should be able to login now. As you may guess, i was not a lucky one, and I still could not f**** login. So i had to press
ctr+Alt+F2
again and do the following:Now i could login finally.
Now it is the time to set the paths and check the installations.
type:
it should show you that you have cuda 8.
Also just in case you can also do these:
add these at the end:
Save and exit gedit. Type:
A question for the people who knows more than me:
So everything sounds like working but when I shutdown/reboot my system for a few seconds it shows
So everything sounds like working but when I shutdown/reboot my system for a few seconds it shows “Failed to start Load Kernel Modules” I tryied this post but it is not helping, please let me know if you know how to fix it.
----------------
Edited-Updated
Guess what, I screwed again.
But this time I came with a much easier solusion. and here is the main point: Sometimes we need to say NO
Here is what works really good for me. after you purge and remove everything and sudo reboot do this:
press
ctr+alt+F2
type your username and passwordnow type these:
IMPORTANT: during the installation, the first question asks for reinstalling the driver again, SAY NO to this mother f**** question Say yes to the rest of them though :D after finishing.
login to your dear PC
Did it work? Your Welcome :)
I got it to work after reading several posts: I had an ATI card in the computer already which turned out to be very useful. I installed GTX 1070 along side of the ATI and started installing Kubuntu 16.04. Only the display connected to the ATI card had image initially, which allowed me to install the driver NVIDIA-Linux-x86_64-367.27.run downloaded from the vendor's website. To install CUDA, I downloaded the cuda_7.5.18_linux.run file. I installed the cuda toolkit by using two switches:
cuda_7.5.18_linux.run --silent --toolkit
The cuda samples can also be installed from the .run file. One issue was cuda does not like gcc5. So I did
sudo apt-get install gcc-4.8
and then changed the default gcc to this version by:I replaced gcc to gcc5 after cuda is installed. Compiling the cuda samples also need to be done with gcc4.8, gcc4.9 might work but I did not try it.
I wrote a blog post on this a while ago - Nvidia CUDA toolkit installation - ubuntu 16.04 LTS - notes/
My environment: Dual boot Windows 10 and Ubuntu 16.04 LTS.
Posting some major learnings here. Please see the blog post for detailed instructions (just to avoid duplication)
The steps that worked for me:
sudo apt-get install nvidia-cuda-toolkit OR 1'. the installation instructions here
You need to select from Software&Updates/Additional Drivers the nvidia driver (375, in my context)
Follow the blue screen when you restart and only from there disable secure boot by inputting your password set during nvidia driver install. (any secure boot disabling through the BIOS did not work for me).
Now the installation test output is successful.
A generally preferred method is to install SW is via deb files when available as they provide a more robust way to handle dependencies and a more reliable method for removing SW. The CUDA 8.0 release-candidate was available for 16.04 (in the dev zone) that way and now the CUDA 8.0 for Ubuntu 16.04 is available via deb files (local) and (network) :https://developer.nvidia.com/cuda-downloads
This worked for me
Press Alt + f1
and reboot
Just a kind reminder, Ubuntu 16.04 might not install cuda at the assumed location
/usr/local/cuda-8.0.61
. Henceexport PATH=/usr/local/cuda-8.0.61/bin${PATH:+:${PATH}}
may not work.When I was trying to install "cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb" on Ubuntu 16.04, I simply followed the instructions here http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#post-installation-actions. However, I was not able to compile cuda-install-samples-8.0.61.sh \home or nvcc -V
It turned out that Ubuntu installed cuda in
/usr/local/cuda-8.0
instead of the assumed location/usr/local/cuda-8.0.61
. Hence I changedexport PATH=/usr/local/cuda-8.0.61/bin${PATH:+:${PATH}}
intoexport PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
and I successfully installed cuda.