Ubuntu系统下安装Theano和Keras的方法
Theano和Keras是两个非常流行的深度学习库,它们可以帮助我们在Ubuntu系统下快速搭建深度学习环境,本文将详细介绍如何在Ubuntu系统下安装Theano和Keras。
安装依赖库
在安装Theano和Keras之前,我们需要先安装一些依赖库,请打开终端,输入以下命令:
sudo apt-get update sudo apt-get install python-dev python-pip libopenblas-dev liblapack-dev gfortran
这些命令将更新软件包列表并安装Python开发环境、pip、OpenBLAS、LAPACK和GFortran编译器。
安装Theano
1、我们需要从GitHub上克隆Theano的源代码,在终端中输入以下命令:
git clone https://github.com/Theano/Theano.git
2、进入Theano源代码目录:
cd Theano
3、使用pip安装Theano:
pip install -r requirements.txt python setup.py install
4、安装完成后,我们可以测试一下Theano是否安装成功,在终端中输入以下命令:
theano-test.py
如果看到类似以下的输出,说明Theano已经成功安装:
Using gpuarray backend. Device 0: GRID K520 (CNMeM is disabled) x86_64 Ubuntu, 2070.96 MiB RAM, compute capability 3.5, cuDNN 511, TensorFlow 1.12.0, OpenCL 1.2 cl_double overclocked to 1100 Mhz, SSE4.1/4.2/AVX instructions enabled, using clocksource tsc, Windows is disabled, Python version 3.5.2 |EPD 7.1| (default, Jul 15 2017, 17:32:09) [GCC 5.4.0 20160609] build options: --compiler=mingw32 --include_path=/home/user/anaconda3/include --library_path=/home/user/anaconda3/libs --math_lib=mkl --mkl_include_path=/home/user/anaconda3/include/mkl --mkl_lib_path=/home/user/anaconda3/libs --with-fPIC --with-float=float32 --with-nvcc --with-no_cuda_framework --enable_language_c --with_python_dir=/home/user/anaconda3/lib/python3.5/site-packages/theano --with-configfile=config.theanorc --with-mode=FAST_RUN,NO_UPDATES,DEBUG_MODE build on Aug 29 2017 15:48:48 by user from /home/user/theano_installation/theano`
安装Keras
1、我们需要从GitHub上克隆Keras的源代码,在终端中输入以下命令:
git clone https://github.com/keras-team/keras.git
2、进入Keras源代码目录:
cd keras
3、使用pip安装Keras:
pip install -r requirements.txt python setup.py install
4、安装完成后,我们可以测试一下Keras是否安装成功,在终端中输入以下命令:
python -c "import keras; print(keras.__version__)"
如果看到类似以下的输出,说明Keras已经成功安装:
Using Theano backend. Keras version: 2.1.6`