[PYTHON] Build an environment on windows10 where you can try MXNet

I want to use MXNet with Python on Windows

When learning with Deep Learning, I am worried that it will take some time, so Currently, it is MXNet or CNTK that runs at high speed, so I tried to install MXNet. The original document is a little old, is that? Because there was a place I thought I wrote the procedure I built as a memorandum.

download

The latest version of the prebuild version of windows can be downloaded from the following site

https://github.com/yajiedesign/mxnet/releases

First, download the related library package of either vc12 or vc14.

Since python3.5 is built with vc14, select the vc14 base package (about 73MB) accordingly.

Next, download the prebuild version of the main unit. I think cuda is ready, so download the gpu version (about 18MB). Since it is compressed in 7z format, http://forest.watch.impress.co.jp/library/software/7zip/ Download the decompression tool.

Deployment

The documentation says it expands to c: \ mxnet. I created and expanded the following folders as appropriate.

c:\work\mxnet

Deploy 7z for vc14 base package.

Was included. Looking at 3rdparty / cudnn / Readme.txt, it says that you should DL and place cudnn yourself. This time, set cudnn 5.1. By the way, if you look at 3rdparty / cudart /, it says cudart64_80.dll, so it will be a combination of CUDA8.0 64bit + cudnn 5.1 (updated depending on the downloaded version).

I downloaded the file and copied the extracted file under 3rdparty / cudnn.

Next, extract the 2017XXXX_mxnet_x64_vc14_gpu file Copy to prebuildbase_win10_x64_vc14. In the state so far

c:\work\mxnet\prebuildbase_win10_x64_vc14\

It has become.

Python environment settings

The documentation says to run setupenv.cmd and install it with python / setup.py, but first assume it will be used in a virtual environment for mxnet.

Anaconda is convenient as a virtual environment for windows. You can download the full version, but if you want to install from the bare minimum, miniconda is a good choice. Due to the opencv package, the python used is ** 3.5 **.

Virtual environment setting by conda

The virtual environment name is specified with -n, and here it is mxnet (any option is acceptable). After that, specify version 3.5 with python = 3.5. numpy, scipy, cython are required, so set at installation time. ipython is easy to use for testing, so install it as well.

conda create -n mxnet python=3.5 numpy scipy cython ipython

It will be downloaded and installed to something like c: \ Anaconda3 \ envs \ mxnet.

If set successfully, from the command prompt that uses this virtual environment

activate mxnet

It becomes a state to use the virtual environment.

MXNET PATH setting

If you look at setupenv.cmd, the path setting to the 3rdparty folder will be added to your PATH. However, it fails if the PATH string already exceeds 1024.

Here, you need to add the absolute path of the following folders to the environment variable PATH.

In short, I created a script to set these PATHs. As a file called c: \ work \ mxnet \ mxnetenv.bat

set MXNET_HOME=c:\work\mxnet\prebuildbase_win10_x64\vc14
set MXNET_DEPEND=%MXNET_HOME%\3rdparty
set MXNET_PATH=%MXNET_DEPEND%\openblas\bin;%MXNET_DEPEND%\gnuwin;%MXNET_DEPEND%\vc;%MXNET_DEPEND%\opencv;%MXNET_DEPEND%\cudart;%MXNET_DEPEND%\cudnn\bin;%MXNET_HOME%\lib
set PATH=%MXNET_PATH%;%PATH%

Created. ** Reset MXNET_HOME to your own path **. If you want to use mxnet, start this mxnetenv.bat first.

Installed as a python package

At this point, you're ready to install it as a python package. It is written as expanded to c: \ work \ mxnet, but please read as appropriate.

activate mxnet
cd c:\work\mxnet
mxnetenv.bat
cd %MXNET_HOME%\python
python setup.py install

Meaning,

--Switch to the virtual environment python 3.5 mxnet you set up earlier --Move to the installed folder --Added mxnet's 3rdparty dependent library path to environment variable PATH --Move to python folder --Installed on site-package in virtual environment using setup.py

Then, the setting will start and the installation will be completed while downloading other missing libraries.

test

Now check if you have installed it. Start python in a virtual environment

import mxnet as mx
a = mx.nd.ones((2,3))
print((a*2).asnumpy())

If there is no error, it will be as follows (here, ipython was used)

(mxnet) c:\work\mxnet> ipython
In [1]: import mxnet as mx
In [2]: a = mx.nd.ones((2, 3));
In [3]: print ((a*2).asnumpy());
[[ 2.  2.  2.]
 [ 2.  2.  2.]]

Addition of verification environment

I installed OpenCV3 and jupyter because it's inconvenient to do anything.

conda install -c menpo opencv3
conda install jupyer matplotlib

(OpenCV3 packages are not standard. This is why we decided to use 3.5 as it is not currently distributed for python3.6)

jupyter-notebook

So, launch jupyter, create a new file with "New"-"Python3", and test whether the previous test command passes.

Also, in the MXNet tutorial, there is also a sample to draw a graph, so It is better to install graphviz in advance.

at the end

I think that you can now use the latest version of mxnet, but testing such as mnist is the next opportunity ...

Recommended Posts

Build an environment on windows10 where you can try MXNet
Build Python environment on Windows
Build python environment on windows
Introducing Kaggle's Docker Image on Windows to build an environment
[Windows] Library Keras course where you can try Deep Learning immediately-Part 1
Python 2.7, 3.4, 3.5 extension module build environment on Windows
Build an LNPP environment on Amazon Linux 2
Building an environment for "Tello_Video" on Windows
[Windows] A library where you can try Deep Learning immediately Keras course-Part 2
Simply build a Python 3 execution environment on Windows
Build an Arch Linux environment on Raspberry Pi
Build TensorFlow on Windows
Try FEniCS on Windows!
Build XGBoost on Windows
Try Poerty on Windows
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
Build an OpenCV4 environment on Raspberry Pi using Poetry
Build a GVim-based Python development environment on Windows 10 (1) Installation
Create an OpenAI Gym environment with bash on Windows 10
Build a machine learning environment natively on Windows 10 (x64)
Let's get started with Python ~ Building an environment on Windows 10 ~
Build an Ubuntu python development environment on Google Cloud Platform
Build an Anaconda virtual environment
Prepare Chainer environment on Windows
Try using OpenCV on Windows
Build a GVim-based Python development environment on Windows 10 (2) Basic settings
Django environment development on Windows 10
[Tensorflow] Tensorflow environment construction on Windows 10
Anyone can understand how to build an initial environment for Python on Mac September 2016 (pyenv + virutalenv)
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
Try using virtualenv, which can build a virtual environment for Python
Build and try an OpenCV & Python environment in minutes using Docker
Try running Discord Bot on an iPhone you no longer use
Python environment construction memo on Windows 10
Anaconda python environment construction on Windows 10
Install python2.7 on windows 32bit environment
Build and install OpenCV on Windows
Create a Linux environment on Windows 10
Install Python development environment on Windows 10
Build Python 3.8 + Pipenv environment on Ubuntu 18.04
Build a python3 environment on CentOS7
[Definitive Edition] Building an environment for learning "machine learning" using Python on Windows
Build an environment with pyenv, pyenv-virtualenv, jupyter on OS X El Capitan
Try to build python and anaconda environment on Mac (by pyenv, conda)
Build Linux on a Windows environment. Steps to install Laradock and migrate
[UE4] Build DedicatedServer on Windows and Linux
Build an environment for Blender built-in Python
Try using Bash on Windows 10 2 (TensorFlow installation)
Build an NFS server on Arch Linux
You can use Dash on Jupyter jupyter_dash
Creating a python virtual environment on Windows
Build Python environment with Anaconda on Mac
Build WordPress on CentOS 8 in LAMP environment
Create an OpenCV3 + python3 environment on OSX
Build OpenCV-Python environment on Raspberry Pi B +
I built a TensorFlow environment on windows10
Build a Python + OpenCV environment on Cloud9
Building an environment for "Tello_Video" on Raspbian
How to build an environment when you want to use python2.7 after installing Anaconda3
How to build an environment for using multiple versions of Python on Mac
A story about building an IDE environment with WinPython on an old Windows OS.