Cited articles
1. Python 2.7, Ubuntu14.04 as the base environment
# Ubuntu/linux 64-bit, CPU only, Python 2.7:
$ sudo pip install--upgrade https://storage.googleapis.com/tensorflow/l INUX/CPU/TENSORFLOW-0.8.0-CP27-NONE-LINUX_X86_64.WHL
# ubuntu/linux 64-bit, GPU enabled, Python 2.7. Requires CUDA Toolkit 7.5 and CuDNN v4. With GPU acceleration, you need to install Cuda and CUDNN
# for other versions, see "Install from sources" below.
$ sudo pip install--upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.8.0-cp27-none-linux_ X86_64.whl
The author uses the TensorFlow package that contains the GPU enabled, so here are the appropriate notes for problems during installation
After performing the corresponding TensorFlow installation command, start the installation of Cuda and CUDNN
Download and install Cuda Toolkit 7.5 or 8.0
Https://developer.nvidia.com/cuda-toolkit-archive
Select the Deb (local) package or the Deb (network) package
Pass the package to Ubuntu and execute the following command in the appropriate directory
sudo dpkg-i Download the appropriate Deb package name. deb
sudo apt-get update
sudo apt-get install Cuda
Wait for the installation to complete
Download and install CUDNN Toolkit 6.5
Baidu search the corresponding package cudnn-6.5-linux-x64-v2.tgz download
Unzip and copy the CUDNN file to the Cuda Toolkit installation path. Assuming that Cuda Toolkit is installed in/usr/local/cuda, execute the following command:
Tar xvzf cudnn-6.5-linux-x64-v2.tgz
sudo cp cudnn-6.5-linux-x64-v2/cudnn.h/usr/local/cuda/include
sudo cp cudnn-6.5-linux-x64-v2/libcudnn*/usr/local/cuda/lib64
sudo vim ~/.BASHRC Open the "./BASHRC" file, and then
At the end of the open file, add the following code and Save:
Export ld_library_path= "$LD _library_path:/usr/local/cuda/lib64"
export Cuda_home=/usr/local/cuda
Note: Cuda is installed by default under the/usr/local/cuda folder
2. Error handling
After entering the TensorFlow test code:
If the Libcudart.so.7.5:cannot open shared object file:no such file or directory error appears:
Workaround, take cuda-8.0 as an example
Due to the version issue, a corresponding soft link is established
Ln-s/usr/local/cuda-8.0/lib64/libcudart.so.8.0/usr/lib
ln-s/usr/local/cuda-8.0/lib64/libcudart.so.8.0/usr/ lib/libcudart.so.7.5
sudo ldconfig
If a corresponding CUDNN error occurs, it is possible that the CUDNN is not installed and is copied according to the above steps
3. TensorFlow Test Code
$ python
>>> import tensorflow as tf
>>> hello = tf.constant (' Hello, tensorflow! ')
>>> sess = tf. Session ()
>>> print sess.run (hello)
Hello, tensorflow!
>>> a = Tf.constant (ten)
>>> B = tf.constant (+)
>>> print Sess.run (a+b)
42
4. Other Operations
4.1 If you upgrade the appropriate CUDNN file, to remove the old version of free space, use the command
Apt-get Autoremove
4.2 If you want to establish a soft link in the/usr/local directory, such as the Cuda link to cuda-8.0
The following commands can be executed (with caution)
# RM-RF Cuda
# ln-s cuda-8.0 cuda
# ldconfig/usr/local/cuda/lib64
Remember to add ldconfig, which may cause error errors while loading shared libraries
4.3 Delete tensorflow
sudo pip uninstall TensorFlow
4.4 Removing Cuda
To the appropriate version directory, take 7.5 for example
sudo/usr/local/cuda-7.5/bin/uninstall_cuda-7.5.pl
If there is no corresponding file, execute the following command
sudo apt-get purge cuda
sudo apt-get autoremove
4.5 Removing the display driver
Sudo/usr/bin/nvidia-uninstall
If not found, use the command
sudo apt-get install autoremove--purge nvidia*