Reprint Please specify:
Look at Daniel's small freshness : http://www.cnblogs.com/luruiyuan/
This article original website : http://www.cnblogs.com/luruiyuan/p/6660142.html
The Ubuntu version I used was 16.04, and using Gnome as the desktop (which doesn't matter) has gone through a lot of twists and turns and finally completed the installation of Keras with TensorFlow as the back end.
Installation of the TENSORFLOW-GPU version:
1. Download CUDA 8.0
Address: Https://developer.nvidia.com/cuda-downloads
Install the following version:
2. Download CuDNN v5 (Here i download is V6, but it turns out that TensorFlow does not directly support V6, unless you build the V6 yourself, otherwise the following tutorial installed TensorFlow can only load v5)
Address: HTTPS://DEVELOPER.NVIDIA.COM/CUDNN
You need to login/register before you can download
3. Install the NVIDIA driver:
First open the terminal, enter the instructions, update the application list
sudo apt-get update
Thanks to the strong support of the Linux community, we can install the driver in a very concise way:
Press the win button to open the menu,
Then enter in the above type to search: Additional drivers Open "Additional drivers--additional Driver" and select the NVIDIA driver that matches your graphics card, and here I am
Using Nvidia binary drivers (375)
Then choose Apply Changes, where the installation may fail, at which point you can continue to choose to apply the changes, install multiple times
When the installation is complete, select restart
4. GCC down version
CUDA8.0 does not support GCC 5.0 and above compilers, and the system comes with 5.4 and later, so we need to reduce the version, or will be in the back error
Enter the following command in terminal to reduce the GCC version to 4.9
sudoApt-getInstallg++-4.9sudoUpdate-alternatives--Install/usr/bin/GCC GCC/usr/bin/GCC-4.9 -sudoUpdate-alternatives--Install/usr/bin/GCC GCC/usr/bin/GCC-5 TensudoUpdate-alternatives--Install/usr/bin/g++ g++/usr/bin/g++-4.9 -sudoUpdate-alternatives--Install/usr/bin/g++ g++/usr/bin/g++-5 TensudoUpdate-alternatives--Install/usr/bin/cc cc/usr/bin/GCC -sudoUpdate-alternatives--setcc/usr/bin/GCCsudoUpdate-alternatives--Install/usr/bin/c++ C + +/usr/bin/g++ -sudoUpdate-alternatives--set C + +/usr/bin/g++
5. Installing CUDA 8.0
cd/media/your username/toshiba\ ext/alu/cuda/8.0sudo dpkg-i cuda-repo-ubuntu1604-8- 0-rc_8. 0.27-1_amd64? Debsudo apt-get updatesudoinstall cuda?
6. Installing CuDNN
CD cd/media/your user name/toshiba\ ext/alu/cuda/ # Enter the path to the CuDNN installation file tar xvzf cudnn-8.0- Linux-x64-v6. 0 . tgz # Unzip sudo CP cuda/include/cudnn.h/usr/local/cuda/include # Copy to include sudocp cuda/ lib64/libcudnn*/usr/local/cuda/lib64 # Copy to lib64 in sudochmod a+r/usr/local/cuda/ include/cudnn.h/usr/local/cuda/lib64/libcudnn* # header file copied in
7. Configuring CUDA Environment variables
Turn on GPU support:
According to the official website tutorial
We type the following command in Terminal:
sudo gedit ~/.bash_profile # Open. Bash_profile This is the user's environment variable, not the global
Then, at the end of the open text, add:
Export ld_library_path="$LD _library_path:/usr/local/cuda/lib64:/usr/local/cuda/extras/cupti/lib64 "export cuda_home=/usr/local/cuda
After saving and closing, enter the following command to make the environment variable effective:
SOURCE ~/.bash_profile # makes the changed environment variable effective
After the installation is complete, the driver must be inspected by the following two commands:
1. nvidia's setup interface
Nvidia-settings # Open NVIDIA Setup interface
This command opens the following interface:
2. NVIDIA GPU List
Nvidia-smi
This command generates a list of GPUs in the terminal, for example, I have only one GPU here
Some people online to copy others ' blog, said nvcc-v can verify, after I measured, there is nvcc-v normal output but the driver is still installed failure phenomenon, therefore, the above verification method is not credible .
8. Installing python3.5.2
Because tensorflow1.0 is better for python3 support and currently only supports python3.5.2, we choose Python 3.5.2.
Install using the Linux version of anaconda3-4.2.0, with the following address:
https://repo.continuum.io/archive/.winzip/
After the installation is complete, add the environment variable and set it as the default Python interpreter
First open the file for the environment variable
Gedit ~/.BASHRC
Then add the path to the Anaconda3 at the end of the file
Export path=/home/your path/anaconda3/bin: $PATH
And finally make our changes effective
SOURCE ~/.BASHRC
This way, we enter Python in terminal and the default is open Anaconda3
So we can use the Python3 safely.
9. Installing Keras and TensorFlow
With the above installation process, the default PIP in our system will be the PIP in Anaconda3, so we only need to use PIP to install Keras and TensorFlow to Anaconda.
Execute the following command:
Install TENSORFLOW-GPU Keras # installs GPU version of TensorFlow and Keras
Once the installation is complete, we can verify the success by using the following command:
" Import Keras "
If you see the following output, it means that the installation was successful
Of course, I installed here CuDNN due to the version is too high, temporarily can not be supported by PIP installation TensorFlow, if changed to CuDNN V5 will be able to support the normal.
I hope this article can help the novice like me.
Resources:
[1]: ubuntu16.04 installation of TensorFlow (GPU acceleration)----Detailed Graphic tutorial
[2]: Ubuntu16.04+cuda8.0+caffe installation Tutorial
Ubuntu installation Tensorflow-gpu + Keras