[PYTHON] Let's Deep Learning on Windows! (VS2013 + caffe + CUDA7.5 + cudnn5.1)

I want to do Deep Learning on Windows

Speaking of deep learning frameworks, Caffe, Tensorflow, Chainer, etc. are famous, but many of them do not support Windows, so until now the environment was built on Ubuntu. (Chainer also works on Windows) But I still want to do it on Windows. So, as a result of trial and error as to whether Caffe can be built on Windows, I managed to build it, so I will note it.

That said, it's not particularly difficult, and the Windows version of Caffe has a link from the official page to the Github repository, so you can build it by following the README. https://github.com/Microsoft/caffe

However, with the above procedure, it must be cudnn3 or cudnn4, or there is no detailed explanation ...

I want to use cudnn 5.1, so I fork the Windows branch of Caffe and use the modified repository for cuDNN v5. The changes are as follows.

・ Include \ caffe \ layers \ cudnn_relu_layer.hpp ・ Include \ caffe \ layers \ cudnn_sigmoid_layer.hpp ・ Include \ caffe \ layers \ cudnn_tanh_layer.hpp ・ Include \ caffe \ util \ cudnn.hpp ・ Src \ caffe \ layers \ cudnn_conv_layer.cu ・ Src \ caffe \ layers \ cudnn_relu_layer.cu ・ Src \ caffe \ layers \ cudnn_relu_layer.cpp ・ Src \ caffe \ layers \ cudnn_sigmoid_layer.cu ・ Src \ caffe \ layers \ cudnn_sigmoid_layer.cpp ・ Src \ caffe \ layers \ cudnn_tanh_layer.cu ・ Src \ caffe \ layers \ cudnn_tanh_layer.cpp

https://github.com/yuzsh/caffe

Execution environment

Preparation

Repository clone (I'll leave the location to you) Download the Windows version of the branch.

git clone -b windows https://github.com/yuzsh/caffe.git

Go to the caffe root directory and copy the properties file.

copy .\windows\CommonSettings.props.example .\windows\CommonSettings.props


 I will omit the installation method of various libraries,
 Please install CUDA and cudnn from [NVIDIA official page](https://developer.nvidia.com/cuda-gpus).
 For Python, it is convenient to use [Anaconda](https://anaconda.org).

 Also, the Python module requires numpy, scipy, matplotlib, scikit-image, and protobuf, so you need to install them. I did the following:
>```activate anaconda2
conda install -y numpy scipy matplotlib scikit-image pip
pip install protobuf

Editing CommonSettings.props

Open. \ Windows \ CommonSettings.props. It will be easier to see if you open it in Visual Studio. Where to check

false //Default is false Set to true for those who cannot use GPU true //Default is true GPU is false for those who cannot use it or who do not need it 7.5 //CUDA version true //Since Python is used, it is true. The default is false. false //Use Matlab or not this time so false(Default) //Various things are written by default, but those who use recent architectures are empty(GTX 1080 etc.) path to your cudnn //$(CuDnnPath)\cuda\To be include C:\Anaconda3\envs\anaconda2 //Python path


 By the way, in Debug mode, if Python is not set to false, an error will occur because Python27_d.lib does not exist.

 Once this is done, I'll change it to "Treat warnings as errors: No" in the project settings, but if I cloned my repository, I've already done so, so I think it's okay.

### Build
 Then open the caffe.sln file and build the solution.
 It takes a lot of time.
 When the build is completed successfully, the exe and dll will be created in Build \ x64 \ Release (or Build \ x64 \ Debug).

### PATH setting
 Add `` `<caffe_root> \ Build \ x64 \ Release \ pycaffe``` to the environment variable PYTHONPATH.
 By the way, [RapidEE](http://www.rapidee.com/en/about) is convenient for handling environment variables in windows.

### Operation check
 Open a command prompt, launch python, and if import caffe passes without error, installation is complete.
 Also, if you go to <CAFFE_HOME> \ Build \ x64 \ Release and execute caffe.exe and the usage message is displayed, you can confirm that the EXE has been generated without any problem.

 As a supplement, samples such as MNIST are written in shell scripts, so it is necessary to prepare an environment and software that can execute this.
 I set it when I put in git.


 That is all.
 I think it was easier than Ubuntu.

 By the way, chainer can be installed only with `` `pip install chainer```.






Recommended Posts

Let's Deep Learning on Windows! (VS2013 + caffe + CUDA7.5 + cudnn5.1)
Set up AWS (Ubuntu 14.04) for Deep Learning (install CUDA, cuDNN)
Install CUDA10.1 + cuDNN7.6.5 + tensorflow-2.3.0 on Ubuntu 18.04
The easiest way to get Chainer v1.5 + CUDA + cuDNN on Windows
How to install Deep Learning framework Caffe on Mac in CPU mode
Summary Note on Deep Learning -4.2 Loss Function-
How to update to Chainer 2.0 (Windows + CUDA 8.0 + CUDNN)
Accelerate Deep Learning on Raspberry Pi 4 CPU
Deep Learning technology go leela on linux
[Windows 10] "Deep Learning from scratch" environment construction
Summary Note on Deep Learning -4.3 Gradient Method-
Deep Learning
An amateur tried Deep Learning using Caffe (Introduction)
Good book "Deep Learning from scratch" on GitHub
Build procedure of TensorFlow 2.2.0-rc0 (CUDA10.2 + cuDNN7.6.5) --Windows10
Install the latest Cuda + CuDNN on Ubuntu 18.04 @ Spring 2020
An amateur tried Deep Learning using Caffe (Overview)
Python vs Ruby "Deep Learning from scratch" Summary
Steps to build PyTorch 1.5 for CUDA 10.2 on Windows