Directory
- Deep learning environment Construction: tensorflow1.4.0+ubuntu16.04+python3.5+cuda8.0+cudnn6.0
- Reference
- Hardware Description:
- Software Preparation:
- 1. Installing Ubuntu16.04
- 2. Install the video driver
- 3. Installing Cuda8.0
- 4. Installing Cudnn6.0
- 5. Tsinghua Source Installation Anaconda
- 6. Installing TensorFlow
- 7. Verify your Installation
- Run a short TensorFlow program
- 8. Uninstall cudnn5.1 upgrade to cudnn6.0
Deep learning environment Construction: tensorflow1.4.0+ubuntu16.04+python3.5+cuda8.0+cudnn6.0reference
Https://zhuanlan.zhihu.com/p/31430631?utm_source=com.tencent.tim&utm_medium=social&utm_oi= 1002237860644270080
Hardware Description:
Graphics card: gtx-1080,8g memory
NVIDIA Corporation Device 1b80
Software Preparation:
Deep learning environments must be adaptable, not versions must match, and these libraries have dependencies.
My environment is used to:
- Ubuntu 16.04
- Python3.5 # TensorFlow cannot fully support version 3.6, 3.5 is more stable
- Cuda8.0 # currently Ubuntu16.04 to cuda8.0 version support is better, while TensorFlow is not very friendly to cuda9.0, so we choose Cuda8.0
- Cudnn6.0
- Tensorflow1.4.0
1. Installing Ubuntu16.04
Download the image from the Ubuntu website and install it with a USB stick.
Update the system after installation is complete.
sudo apt-get update sudo apt-get upgrade
2. Install the video driver
can refer to https://www.cnblogs.com/pprp/p/9430836.html
Pro-Test available, but need to pay attention to the need to go to the NVIDIA network to download the appropriate version of their own computer (NVIDIA Web page can measure your computer's model), the specific installation process refer to the above blog.
Restart the computer, through the nvidia-smi
command to view the driver information, if successful display, then the driver installation success
3. Installing Cuda8.0
Download the appropriate Cuda version from Nvidia official website Https://developer.nvidia.com/cuda-release-candidate-download, The latest version of the current official website is 9.0, but I very much do not recommend that you use the latest version.
We chose the Linux platform and downloaded runfile. Implementation
sudo ./cuda_8.0.61_375.26_linux.run
We have installed 384, this step to choose N, the rest of the way yes.
Finally, we need to configure the environment variables so that our installed Cuda takes effect.
(1) Open sudo gedit ~/.bashrc, add two lines on the last side as follows:
export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
(2) Set environment variables and dynamic link libraries, open sudo gedit /etc/profile
, add at the end of the file:
export PATH=/usr/local/cuda/bin:$PATH
(3) Create a linked file, open it sudo gedit /etc/ld.so.conf.d/cuda.conf
, and add it to the file:
/usr/local/cuda/lib64
Final execution sudo ldconfig
, so that the above settings take effect immediately.
Test Cuda:
Execute the following command:
CD ~/nvidia_cuda-8.0_samples/1_utilities/devicequery
Make
./devicequery
Can see the details, the final result is pass, then Cuda installation success, otherwise is where there is a problem (using Google and Baidu to solve).
4. Installing Cudnn6.0
On the Nivida developer website, find the CUDNN download page:? https://developer.nvidia.com/rdp/cudnn-download?, select Download Cudnn v6.0 (April 27, 2017 ), "CuDNN v6.0 Library for Linux" in for CUDA 8.0 ":
After downloading the installation is very simple, is extracted and then copied to the corresponding system Cuda path:
tar -zxvf cudnn-8.0-linux-x64-v6.0.tgzsudo cp cuda/include/cudnn.h /usr/local/cuda/include/sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/sudo chmod a+r /usr/local/cuda/include/cudnn.hsudo chmod a+r /usr/local/cuda/lib64/libcudnn*
5. Tsinghua Source Installation Anaconda
https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
By adding a source, you can speed up
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/conda config --set show_channel_urls yes
It is recommended to choose anaconda3-4.2.0-linux-x86_64.sh (version 4.2) to install, because support python3.5, through the command chmod +x Anaconda3-4.2.0-Linux-x86_64.sh
& ./Anaconda3-4.2.0-Linux-x86_64.sh
can be installed, the installation process according to the prompts can be, relatively simple.
6. Installing TensorFlow
Reference official website: Https://www.tensorflow.org/install/install_linux?hl=zh-cn#InstallingAnaconda
First create a Anaconda virtual environment:
conda create -n tensorflow python=3.5
Activate the Conda environment by issuing the following command:
source activate tensorflow
Issue commands in the following format to install TensorFlow in the Conda environment:
pip install --ignore-installed --upgrade tensorflow-gpu==1.4.0
7. Verify that your installation runs a short TensorFlow program
Call Python from the shell as follows:
$ python
In the Python interactive shell, enter the following lines of short program code:
# Pythonimport tensorflow as tfhello = tf.constant('Hello, TensorFlow!')sess = tf.Session()print(sess.run(hello))
If the system outputs the following, you can start writing the TensorFlow program:
Hello, TensorFlow!
If your system outputs an error message instead of a greeting, see common installation issues.
8. Uninstall cudnn5.1 upgrade to cudnn6.0
1. Extract a folder named Cuda, folder with include and lib64 two folders
2, delete the original CUDNN
sudo rm -rf /usr/local/cuda/include/cudnn.hsudo rm -rf /usr/local/cuda/lib64/libcudnn*12
3, install the installation need version of CUDNN, in the terminal CD to the newly unpacked Cuda folder
sudo cp include/cudnn.h /usr/local/cuda/include/sudo cp lib64/lib* /usr/local/cuda/lib64/12
4, CD to/usr/local/cuda/lib64/folder, establish a soft link (note the version number for your own)
sudo chmod +r libcudnn.so.5.0.5 sudo ln -sf libcudnn.so.5.0.5 libcudnn.so.5 sudo ln -sf libcudnn.so.5 libcudnn.so sudo ldconfig 1234
5. Testing
cd /usr/local/cuda/lib64/ll12
CUDNN Version Update complete
Deep learning environment Construction: tensorflow1.4.0+ubuntu16.04+python3.5+cuda8.0+cudnn6.0