Install Cuda On Ubuntu

Cuda 8.0 needs gcc 5.3.1 but cuda 9.0 is compatible with gcc 6.3.0 which is installed on ubuntu 17.04 automatically. Share| improve this answer answered Aug 27 '17 at 19:22.

Active1 year, 11 months ago

My ubuntu version is 17.04. Does this mean my Linux currently can't install CUDA? I want to install TensorFlow with GPU support.

Per suggestion:

talonmies
61.1k17 gold badges141 silver badges209 bronze badges
user697911user697911
3,54412 gold badges42 silver badges82 bronze badges

5 Answers

above is the correct one.

apt-get install nvidia-cuda-toolkit

but remember the cuda installed through apt were installed in different location. manually create ln -s at /usr/local/cuda for include,lib64,and bin

skywalkerytxskywalkerytx

I have successfully installed CUDA 8.0 + the latest patch from NVIDIA on Ubuntu 17.04:

  1. Download the .run file from https://developer.nvidia.com/cuda-downloads, choosing Ubuntu 16.04 (Base Installer)
  2. You will not be able to install it by just running, because it is looking for a file called InstallUtils.pm which is not present in Ubuntu 17.04, but curiously, is present in the .run file - so: unpack the .run file using ./cuda*.run --tar mxvf
  3. copy InstallUtils.pm (should be in the /bin path) to /usr/lib/x86_64-linux-gnu/perl-base
  4. Run the installer (You may want to say no to the driver install step to keep the one you install through apt - I'm using 381.22, because 375.26, which is provided by the .run file does not support my 1080ti)
  5. gcc 6 is incompatible with CUDA, but this is easily remedied for compiling the sample files: just add export EXTRA_NVCCFLAGS='-Xcompiler -std=c++98' to your bashrc file, and comment out

from one of the headers (I think it was host_config.h, but you'll see it once you try to compile) - comment out these lines:

This is all from memory, so hopefully it's accurate enough.

I managed to find this solution thanks to these useful posts:

Mr.WorshipMeMr.WorshipMe

For ubuntu 17.04, I had to use cuda 9.0 (deb version)https://developer.nvidia.com/cuda-release-candidate-download

I couldn't get it to work otherwise. Cuda 8.0 needs gcc 5.3.1 but cuda 9.0 is compatible with gcc 6.3.0 which is installed on ubuntu 17.04 automatically.

dr.purpledr.purple

More precisely, this is what I did:

On Ubuntu 17.04, install CUDA 9.0 — you can currently download the beta version https://developer.nvidia.com/cuda-release-candidate-download

I downloaded the .deb file and haven’t had any problems — follow the steps they recommend when you download cuda 9.0

sudo dpkg -i cuda-repo-ubuntu1704-9-0-local-rc_9.0.103-1_amd64.deb

sudo apt-key add /var/cuda-repo-9.0-local-rc/7fa2af80.pub

sudo apt-get update

sudo apt-get install cuda

Then follow the post installation steps from the nvidia instructions (i.e., setting PATH and LD_LIBRARY_PATH) http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#post-installation-actions)

export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}

export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64 ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Cuda 9 is compatible with gcc 6.3.0 (which comes with 17.04). I used arch=sm_52 and sometimes for my make files have to go ‘make clean’.

dr.purpledr.purple

Installing Cuda 9.0 was the simplest solution in my case.

Alternatively, if you'd prefer cuda 8, you can download the deb file and then use the command

dpkg-deb -x cuda_8.*.deb /usr/local/cuda-8.0

to extract the contents from the deb file and have them placed in the desired directory.

Source: http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#advanced-setup)

Ubuntu
N.B.N.B.

Not the answer you're looking for? Browse other questions tagged tensorflowcuda or ask your own question.

We have discussed about GPU computing as minimally needed theoretical background. Also, in an earlier guide we have shown Nvidia CUDA tool installation on MacOS X. Here is Practical Guide On How To Install PyTorch on Ubuntu 18.04 Server With Nvidia GPU. Installation demands server architecture which has Nvidia graphics card – there are such dedicated servers available for various purposes including gaming. Installing on localhost for intense and time consuming work not recommended for the sake of life of the device. The graphics card must support at least Nvidia compute 3.0 for more works than just PyTorch.

Steps on How To Install PyTorch on Ubuntu 18.04 Server

SSH to server. Update and upgrade :

2
apt upgrade-y

We can see what graphics card hardware installed by running :

Install Cuda On Ubuntu 18

We need Nvidia driver installed. We can check whether and what graphics driver on SSH:

If no driver is installed or latest driver needed then unlike our MacOS X Nvidia CUDA guide, we have multiple options.

Ubuntu Default Recommended Driver more than good. Nouveau is the open source implementation of the Nvidia driver.
Official Nvidia Site is for official drivers but they do not upgrade automatically. Here are Ubuntu’s PPA, browse it :