I just installed Tensorflow GPU on Ubuntu 18.04. There are a lot instructions for it, however I think the fastest and easiest way is usually not used and I want to share it:
sudo sh cuda_9.0.176_384.81_linux.run --override
sudo ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++
cd ~
sudo nano .bashrc
add at the end of the file:
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}}
CTL+X to save and exit
CuDNN:
register at nvidia developers https://developer.nvidia.com/cudnn
Download 9.1 runtime & developer library for 16.04 (Files cuDNN v7.1.3 Runtime Library for Ubuntu16.04 (Deb) & cuDNN v7.1.3 Developer Library for Ubuntu16.04 (Deb))
Open the files with software manager and install them.
Check with:
cat /usr/include/x86_64-linux-gnu/cudnn_v*.h | grep CUDNN_MAJOR -A 2
Just to extend Jonny's answer: when following Jonny's method for installing CUDA, I had to choose "No" for "Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?" (yes or default for everything else). Otherwise the CUDA driver installation would fail saying "ERROR: An NVIDIA kernel module 'nvidia-drm' appears to already be loaded in your kernel"
Then you can test your CUDA installation by running the samples.
I just installed Tensorflow GPU on Ubuntu 18.04. There are a lot instructions for it, however I think the fastest and easiest way is usually not used and I want to share it:
NVIDIA DRIVER:
CUDA:
Normally: "sudo apt install nvidia-cuda-toolkit" However this installs version 9.1, too new at the moment and tensorflow will not run. Instead download CUDA 9.0: https://developer.nvidia.com/cuda-90-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1704&target_type=runfilelocal Then run (Additional Details on the first line can be found at: How can I install CUDA 9 on Ubuntu 17.10):
CuDNN:
register at nvidia developers https://developer.nvidia.com/cudnn Download 9.1 runtime & developer library for 16.04 (Files cuDNN v7.1.3 Runtime Library for Ubuntu16.04 (Deb) & cuDNN v7.1.3 Developer Library for Ubuntu16.04 (Deb)) Open the files with software manager and install them. Check with:
Install libraries and tensorflow:
Check:
Note: Start tensorflow or your development environment from terminal, otherwise for me it does not load the PATH variables.
Just to extend Jonny's answer: when following Jonny's method for installing CUDA, I had to choose "No" for "Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?" (yes or default for everything else). Otherwise the CUDA driver installation would fail saying "ERROR: An NVIDIA kernel module 'nvidia-drm' appears to already be loaded in your kernel"
Then you can test your CUDA installation by running the samples.
First install their dependencies:
These won't compile with the new compilers on Ubuntu 18, so you'll need to downgrade to gcc/g++ 6:
Compile the samples by navigating to:
And compile using:
Run one of the samples like: