Firstly, we should make your Visual Studio 2013 support more C++11 features.
- Download and install Visual C++ Compiler Nov 2013 CTP.
- Copy all files in
C:\Program Files (x86)\Microsoft Visual C++ Compiler Nov 2013 CTP
(or the folder where you extracted the zip archive) toC:\Program Files (x86)\Microsoft Visual Studio 12.0\VC
and overwrite all existed files. Don’t forget to backup the original files before copying.
- NOTICE: You need to register as a NVIDIA community user to get the download link of CuDNN.
Finally, use CMake to create a Visual Studio solution in
./build/
. During configuration, you may need to set the path of each third-party library, until no error is reported. (Set environmental variable OpenBLAS_HOME to the OpenBLAS directory containinginclude
andlib
; set OpenCV_DIR to thebuild
directory after unpacking the OpenCV package.) Open the solution and compile, you will get amxnet.dll
in./build/Release
or./build/Debug
.重点在这里:
1.如果你已经装了VS2015可以不用安装Visual C++ Compiler Nov 2013 CTP.
2.CuDNN需要下载V3版本(0.7版支持CuDnn v5),也就是cudnn-7.0-win-x64-v3.0-prod3.CUDA需要下载最新8.0,7.5虽然兼容Win10但无法完成Mxnet的编译。
4.你需要安装CMake这个软件 cmake-3.6.1.zip
5.你需要把Mxnet项目从github上clone下来,但是国内clone好慢而且老挂,所以我们必然用Download Zip,但由于它引用了其他项目
,下载后会发现引用的项目空有一个文件夹,那就把其他项目也打包下载下来,然后手动解压咯。
1.把Mxnet项目解压完毕(引用项目也解压好)
2.建文件夹build
3.建一个build.bat 里面写
cmake -G "Visual Studio 12 2013 Win64" ..
4.你需要把cmake/bin添加到系统PATH中cmake-gui .如果你用VS2015,改第一个参数为Visual Studio 14 2015 Win64![]()
5.运行build.bat,修改各种参数,点Configure直到通过,放一张图(图上CUDA的路径不对,要用8.0的)
6.you will get amxnet.dll
in./build/Release
or./build/Debug 这就是我们要的东西
7.Customized Building
The configuration of mxnet can be modified by
config.mk
- modify the compiling options such as compilers, CUDA, CUDNN, Intel MKL, various distributed filesystem such as HDFS/Amazon S3/...
- First copy make/config.mk to the project root, on which any local modification will be ignored by git, then modify the according flags.
Building with Intel MKL Support
First,
source /path/to/intel/bin/compilervars.sh
to automatically set environment variables. Then, edit make/config.mk, letUSE_BLAS = mkl
.USE_INTEL_PATH = NONE
is usually not necessary to be modified.
这里以pre-built packages on Window项目进行说明。
1.安装python,2.7以上均可,推荐Windows x86-64 executable installer
2.安装python库numpy,虽然Mxnet提供了py脚本来自动安装,但是由于VS版本问题,各种编译失败,所以直接下载预编译numpy进行安装。
You can find there several wheels for
numpy
: http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy. To get the proper architecture, check in the namewin32
for 32 bits andamd64
for 64 bits. To get the proper Python version, checkcpXX
: first X is major version, and second X is minor version, so for instancecp27
means CPython 2.7.Example:
pip install numpy‑1.9.2rc1+mkl‑cp27‑none‑win32.whl
对于输入pip提示命令不存在什么的童鞋,请将Python27\Scripts加入系统PATH
3.下载Mxnet的各种例子https://github.com/dmlc/mxnet/tree/master/example 我们用到的是image-classification
4.在mxnet-master\example\image-classification 目录下打开cmd,输入 python train_mnist.py -->报错
- 新建文件夹mnist
- 下载Handwritten digits的训练集和测试集,解压到mnist目录下
- 3.修改他们的名字(这是例子上的bug,然而目前并没有修复),如图
4.这下就可以开始训练了,打开cmd,输入python train_mnist.py,参数可以目录下的参考ReadMe.md
如果你是用的是pre-built packages of gpu 你需要加参数--network lenet --gpus 0
5.大功告成!
关注我的微信公众号,欢迎交流讨论哦~