Keras configuration (GPU version, based on GTX1080 and WIN10 )

This is my first blog about machine learning.( •̀ ω •́ )y

To begin with,the most important thing is to configure a group of proper tools and develope environments.
Keras is a well recommended framework by google, which can either supported by tensorflow and theano. Due to the excellent optimization by nvidia, the latest version of nv gamer graphics card (gtx10x0,titan xp)can also largely extend the efficiency of network training. So if one of the card is available, a GPU version of Keras is recommended.

My graphics card is GTX1080, the operating system is windows10 X64.

1. Microsoft Visual Studio 2015

Firstly, if you want to install a GPU version of machine learning framework, a Microsoft visual studio is needed. The version of Microsoft vs(also the CUDA Toolkit mentioned below) depends on your graphics card. If your card doesn’t belong to one of the latest NVidia version (gtx10x0,titan xp),then visual studio 2010~2013 is strongly recommended, because vs2015 is only compatible with cuda8.0,which is the only CUDA version supported by GTX1080. Due to my GTX1080, I’ve chosen vs2015 as my version, which can be de directly downloaded at the following link:

http://download.microsoft.com…

It’s a community version, totally free for individual developer.

The installation of vs2015 is so simple, load the iso file and click the execution file just like all other software.

《Keras configuration (GPU version, based on GTX1080 and WIN10 )》

VS2015 will automatically configure the environment without needing more Settings.

2. Anaconda2 4.4.0

To run Keras framework, a python environment is also needed. You can directly find the open source codes of python on GitHub, but I recommend Anaconda, for it has already integrated a lot of third-party libs (numpy, scipy, matplotlib, ipython, spyder…..). There are 2 version of Anaconda can be accessed, corresponding to python2+ and python3+. I took anaconda2(python2.7 version) as my choise. If you need to do text procession works, py3+ is recommended.

Download it from official site: https://www.continuum.io/down…

《Keras configuration (GPU version, based on GTX1080 and WIN10 )》

It can also be downloaded from the archive of the open source share site of Tsinghua university, choose anaconda2 4.4.0 if you choose python2.7 as environment:
https://mirrors.tuna.tsinghua…

《Keras configuration (GPU version, based on GTX1080 and WIN10 )》

《Keras configuration (GPU version, based on GTX1080 and WIN10 )》

Downloading from the latter can speed up a lot if you are in mainland CHINA.

When installing anaconda, don’t forget add the folder of anaconda scripts and libs to the environment variables.

3. Gcc compiler

Since we chose GPU version of Keras as our derivation machine, a g++ is indispensable.
open command line (win+R, cmd)and tap in the code:

conda install mingw libpython

4. CUDA Toolkit 8.0

It’s the core part if you want to use your powerful GPU to do the batch calculation and derivation.
CUDA Toolkit is provided by NVIDIA to support GPU oriented programming, which is only valid for graphics cards of NVIDIA but not AMD or Intel graphics products. If you have no NVIDIA graphics card, CPU version of Keras deep learning framework can be used.

Go to NVIDIA official site to download CUDA Toolkit, choose your version of operating system.
https://developer.nvidia.com/…

《Keras configuration (GPU version, based on GTX1080 and WIN10 )》

5. install Theano/Tensorflow

Open the CMD, tap in the code one by one:

#Which torch you wanna choose? Theano or Tensorflow?
pip install theano;#pip install tensorflow; 
pip install keras
conda install git
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git

6. Configuration

Add the following path into environment variables:

#Change the disk and folder if you've already chosen another place
C:\Anaconda2;
C:\Anaconda2\Scripts;
C:\Anaconda2\MinGW\bin;
C:\Anaconda2\MinGW\x86_64-w64-mingw32\lib;

create a new variable, add in the PATH:

#Change the dick, folder; change "theano" to "tensorflow" if you chose another
C:\Anaconda2\Lib\site-packages\theano;

create a txt file .theanorc.txt at your USER fold, add in the content:

[global]
openmp=False 
device = gpu   
optimizer_including=cudnn  
floatX = float32  
allow_input_downcast=True  
[lib]
cnmem = 0.8 
[blas]
ldflags=  
[gcc]
cxxflags=-ID:\Anaconda2\MinGW  
[nvcc]
fastmath = True  
--flags=-LD:\Anaconda2\libs #change it to your own directory
--compiler_bindir=D:\Microsoft Visual Studio 12.0\VC\bin #change it to your own directory

#delete all annotation 

Till now, everything has been done.
Open your python environment(cmd or ipython notebook or spyder) and try to import~!

python
import numpy as np
import theano #or 'import tensorflow as tf' 
import keras

If you want to do more, try to use keras and nimst database train a multi-layer perceptron model.

    原文作者:JackieFang
    原文地址: https://segmentfault.com/a/1190000010790486
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞