Keras installation: win10+anaconda3+nvs4200M+cuda9.0+cudnn7.0+tensorflow1.8+keras2.1

Reference article:

Install Keras on native Windows

Keras Installation and Configuration Guide (Windows)

Deep learning environment construction: win10+GTX1060 + tensorflow1.5+keras+cuda9.0+cudnn7

Install the latest Tensorflow1.6 (CUDA9.0+cuDNN7.0) under win10


One, anaconda3 installation

Use anaconda for library installation. Download address: https://repo.continuum.io/archive/index.html

The version I have installed is:



Second, visual studio2017 installation



Three, cuda installation

illustrate:

(1) cuda9.1 was installed at the beginning, and then import tensorflow reported an error.


(2) It was found that the official tensorflow supports up to cuda9.0. If you want to maintain cuda9.1, you can only compile the available tensorflow version yourself, which uses the online resource - the version compiled by Daniel.

(3) Since I am a tensorflow novice, I am very worried about using my own compiled version when installing tensorflow for the first time.

(4) Next, I searched for the version provided by Daniel on the Internet, but found that the requirement is that the graphics card computing power should be above 3, and my current computer Thinkpad T420 graphics card is nvdia 4200M, and the computing power is 2.1. So this way doesn't work either.

(5) Only cuda can be downgraded. Ready to install combination: cuda9.0+visual studio2017+cudnn7.0+tensorflow


1. Download and install

If using gpu acceleration: install cudn; otherwise skip step 2.

https://developer.nvidia.com/cuda-downloads



The following downloads and installations are: base installer and patch3.




If you run the above 3 .exes directly and an error is reported when decompressing, decompress the .exe first, and then run the setup.exe file.




2. Environment variable configuration

Configure the environment variables of cuda below. After installing cuda, two system environment variables will be automatically generated 

CUDA_PATH C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1 
CUDA_PATH_V6_5 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1

Add the following environment variables yourself 

CUDA_BIN_PATH% CUDA_PATH% \ bin

CUDA_LIB_PATH  %CUDA_PATH%\lib\x64

CUDA_SDK_PATH  C:\ProgramData\NVIDIA Corporation\CUDA Samples\v6.5

CUDA_SDK_BIN  %CUDA_SDK_PATH%\bin\win64

CUDA_SDK_LIB  %CUDA_SDK_PATH%\common\lib\x64 

After configuring the environment variables, restart the computer.


3. How to check the cuda version number supported by the computer

Control Panel---Search:nvidia---select NVIDIA Control Panel---Help---System Information---Components




4. Verify the installation of cudn: cmd-->nvcc -V



Four, cudnn installation

Download address: https://developer.nvidia.com/rdp/cudnn-download

The cudnn for cuda9.0 is:


To download from the official website, you need to register an Nvidia developer account. My account password is: [email protected], and the password is Xq881116. Download and decompress the folder named cuda, which contains bin, include, lib. Copy the three folders to the place where CUDA is installed to cover the corresponding folder. The default folder is:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\9.0



Five, pip switch source address

Switch to a domestic mirror to improve the speed and success rate of installation. Create a pip directory in the user directory, such as :\Users\administrator\pip , create pip.ini , and write the following content:

    [global]  
    index-url = http://mirrors.aliyun.com/pypi/simple/  
    [install]  
    trusted-host=mirrors.aliyun.com 

The above is Alibaba Cloud, and other domestic mirrors include:

Tsinghua University: https://pypi.tuna.tsinghua.edu.cn/simple

Aliyun: http://mirrors.aliyun.com/pypi/simple/

University of Science and Technology of China https://pypi.mirrors.ustc.edu.cn/simple/

Huazhong University of Science and Technology: http://pypi.hustunique.com/

Shandong University of Technology: http://pypi.sdutlinux.org/ 

Douban: http://pypi.douban.com/simple/




Six, tensorflow

Open the anaconda prompt and enter pip install --upgrade tensorflow and press Enter. If it is the GPU version, enter pip install --upgrade tensorflow-gpu . After installing the test (in IPython), it is successful to output the result of 32.

>>>import tensorflow as tf  
>>>sess = tf.Session()  
>>>a = tf.constant(10)  
>>>b = tf.constant(22)  
>>>print(sess.run(a + b)) 


安装测试过程:


import tensorflow as tf一开始有如下报错:


报错原因:h5py和numpy不相容,修改numpy类型。tensorflow需要的numpy至少1.13.3以上,所以:pip install numpy==1.13.3


再进行验证,解决。


七、keras

打开anaconda prompt输入pip install keras --pre即可安装。装完了测试下,能正常运行就是成功,他给的示例数据下载的比较慢,需要开启科学上网才行:

>>> conda install git
>>> git clone https://github.com/fchollet/keras.git
>>> cd keras/examples/
>>> python mnist_mlp.py


测试安装过程:


没有报错

conda install git


git clone https://github.com/fchollet/keras.git


cd keras/examples/

python mnist_mlp.py




程序无错进行,至此,keras安装完成。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325844536&siteId=291194637