Ubuntu builds deep learning framework Keras

Source: Internet
Author: User
Tags keras

The Deep learning Framework Keras is based on TensorFlow, so installing Keras requires the installation of TensorFlow:

1. The installation tutorial is mainly referenced in two blog tutorials:

Https://www.cnblogs.com/HSLoveZL/archive/2017/10/27/7742606.html

Https://www.jianshu.com/p/5b708817f5d8?from=groupmessage

2. This tutorial starts with:

The Ubuntu installation tutorial is skipped, starting with the building of the environment needed for deep learning

(It is necessary to note that the reason to write a tutorial is because I have installed a lot of failures, the original was written in the tutorial date (18-06-01), I used the CUDA9.2, but the 9.2 version in the entire environment to build a final import TensorFlow error: "Importerror:libcublas.so.9.0:cannot Open Shared object file:no such file or directory", trying a lot of ways also can not, should Is TensorFlow also not support CUDA9.2, although the document says yes. So this article instead of CUDA9.0 (uninstall Cuda uninstall not clean, forgive me not to use Ubuntu, only reinstall Ubuntu))

first, the installation of CUDA environment:

(1) Download CUDA 9.0:

(2) Open the terminal and switch to the downloaded Deb directory:

$ sudo dpkg-i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb$ sudo apt-key add/var/cuda-repo-<version>/ 7fa2af80.pub$ sudo apt-get update$ sudo apt-get install Cuda

(3) After completion, configure the CUDA environment:

 $sudo  gedit ~/.BASHRC

(4) Add at the end of the file:

Export cuda_home=/usr/local/cuda-9.0export PATH=/usr/local/cuda-9.0/Bin:${path} Export Ld_library_path=/usr/local/cuda-9.0/lib64:${ld_library_path}

(5) After the change is saved:

$ source ~/.BASHRC

(6) Verify that the configuration is successful:

$ nvcc-v

Second , install the CUDNN Acceleration Library:

(1) Download CUDNN 7.14 (corresponding to CUDA9.0): Note that the download is the first for Linux

(When I failed to install, because the tutorial did not mention, I directly Baidu Cudnn, download is with Power8,power9 that, so installed and then import TensorFlow, the error "Importerror: Libcudnn.so.7:cannot open Shared object file:no such file or directory ", tried a lot of methods such as ..., also looked up a lot of methods including StackOverflow, GitHub above Or not, then refer to another deep learning environment tutorial, which is mentioned in the reference tutorial of the second, so entered the right now, and then installed successfully.

(2) Then continue to follow Installation guide and go to the directory where you downloaded the package:

tar -xzvf cudnn-9.0-linux-x64-cuda/include/cudnn.h/usr/local/cuda/  sudo cp cuda/lib64/libcudnn*/usr/local/cuda/sudo chmod a+r/usr/local/cuda/include/ cudnn.h/usr/local/cuda/lib64/libcudnn*

Third , install the Keras frame:

(1) Install the relevant package:

$ sudo pip3 install scikit-learn scikit-image$ sudo pip3 install Tensorflow-gpu  # GPU accelerated version $ sudo pip3 install Keras

Here's an interrupt:

1) If PIP is not installed, that is, "command not found" need to install PIP first, and then use Python3 need to install with PIP3 (Ubuntu16.04 is installed by default two versions of Python, in "/usr/local/lib" Can be seen in python2.7 and python3.5, respectively)

# for Python 3$ sudo apt-get install python3-pip# for python 2$ sudo apt-get install Python-pip

2) When using PIP to install, if you want to speed up the installation, use the domestic mirror, for example:

- I. https://pypi.tuna.tsinghua.edu.cn/simple keras

3) Finally verify the installation success in the terminal:

# Enter Python3. 5 $ python3>>> import tensorflow>>> import Keras

If the error is not, the configuration is successful.

Ubuntu builds deep learning framework Keras

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.