Ubuntu18.04 installation TensorFlow and Keras

 

 

 

TensorFlow and Keras are currently two mainstream deep learning framework, Keras was adopted as the high-level API TensorFlow, usually do deep learning task, you can use Keras as deep learning framework, and with TensorFlow as the back-end engine.

1. Before installing, make sure pip package manager latest:

sudo apt-get update 
sudo apt-get upgrade
sudo apt-get install python-pip python-dev
sudo apt-get install python3-pip python3-dev

When using pip installation package is installed by default python2 package. Python3 want to install the package, use pip3.

2, install Python related libraries

(1) installation BLAS library

 sudo apt-get install build-essential cmake git unzip pkg-config libopenblas-dev liblapack-dev 

(2) install python Science Kit

 sudo apt-get install python-numpy python-scipy python-matplotlib python-yaml 

(3) Installation HDF5. This library was originally developed by NASA, using efficient binary format to save large files of numerical data. (It allows you to save to disk Keras model quickly and efficiently)

 sudo apt-get install libhdf5-serial-dev python-h5py 

(4)安装Graphviz和pydot-ng,这两个包可以将Keras模型可视化。

 sudo apt-get install graphviz 

 sudo pip install pydot-ng

(5)安装python-opencv包

 sudo apt-get install python-opencv 

3、安装CUDA和cuDNN

见另一篇博文:https://www.cnblogs.com/booturbo/p/11834661.html

4、安装支持GPU的TensorFlow

 pip install tensorflow-gpu 

 pip3 install tensorflow-gpu

5、安装Keras

可以从PyPI安装Keras

 sudo pip install keras 

也可以从GitHub安装Keras。这种方式安装,可以运行keras/examples文件夹里的示例。

git clone https://github.com/fchollet/keras
cd keras
sudo python setup.py install

安装完成后,运行下示例脚本,例如 MNIST

在keras文件目录下运行, python examples/mnist_cnn.py 

 运行过Keras之后,就可以在~/.keras/keras.json看到Keras的配置文件,编辑该文件为Keras选择后端引擎,

{
    "image_data_format": "channels_last",
    "epsilon": le-07,
    "floatx": "float32",
    "backend": "tensorflow"
}

 

 

 

 

到此结束。

 

 

 

Guess you like

Origin www.cnblogs.com/booturbo/p/11964075.html