Skip to content

Latest commit

 

History

History
160 lines (108 loc) · 5.43 KB

building-windows.md

File metadata and controls

160 lines (108 loc) · 5.43 KB

BMXNet Installation on Windows

This document describes the build and compilation process of BMXNet. As well as adding the BMXNet Python binding. It is based on those three sources:

  1. BMXNet's Readme: Build the MXNet Python Binding
  2. MXNet's Windows Setup: Build from Source
  3. MXNet's Build/Install Instructions: Verify MXNet with Python

Install Visual Studio

  • Get the Visual Studio Community Edition 2017.

  • During the setup, choose to install the VC++ 2017 version 15.4 v14.11 toolset.

  • After finishing the installation, modify the version by executing:

    "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" -vcvars_ver=14.11

Install CMake

  • Download and install CMake, version 3.12.2 (tested) or higher

Install OpenCV

  • Download OpenVC
  • Extract the files to C:\utils\opencv
  • Define an environment variable using the command line: set OpenCV_DIR=C:\utils\opencv\build

Install OpenBLAS

  • Download OpenBlas
  • Move all extracted files, including the directories include and lib, to C:\utils\OpenBLAS
  • Define a environment variable using the command line: set OpenBLAS_HOME=C:\utils\OpenBLAS

Install CUDA

→ not required if no CUDA-compatible GPU is present

Install cuDNN

→ not required if no CUDA-compatible GPU is present

Install git

→ not required if already installed

Clone the repository

cd C:\
git clone https://github.com/hpi-xnor/BMXNet-v2.git --recursive

Build BMXNet

First, create a build directory:

mkdir C:\bmxnet\build
cd C:\bmxnet\build

Thereafter, build BMXNet by running:

cmake -G "Visual Studio 15 2017 Win64" -T cuda=9.2,host=x64 -DUSE_CUDA=0 -DUSE_CUDNN=0 -DUSE_NVRTC=0 -DUSE_OPENCV=1 -DUSE_OPENMP=1 -DUSE_BLAS=open -DUSE_LAPACK=1 -DUSE_DIST_KVSTORE=0 "C:\bmxnet" 

Take a quick look on the output. It should indicate that OpenBLAS and OpenCV were found.

Compile BMXNet

The process of compiling BMXNet can take a long time (> 30 minutes), depending on your system's performance. For compiling BMXNet run:

msbuild mxnet.sln /p:Configuration=Release;Platform=x64 /maxcpucount

The expected output should look like this:

Build succeeded.

[...]

6 Warning(s)
0 Error(s)

Time Elapsed 00:21:51.44

Set Up the Conda environment

Assuming Anaconda is already installed on your system, run conda create -n bmxnet python=3 in the Anaconda command prompt (see windows start menu).

Thereafter, activate the recently created environment: conda activate bmxnet.

Lastly, install all required packages by running:

pip install numpy scipy matplotlib ipython jupyter pandas sympy nose cpplint==1.3.0 pylint==2.1.1 "numpy<=1.15.2,>=1.8.2" nose-timer "requests<2.19.0,>=2.18.4" h5py==2.8.0 boto3

Install additional files

  • Download mingw64_dll.zip, unzip and copy the libraries (.dll files), which OpenBLAS depends on, to C:\common.
  • Add the folder C:\common to the environment variable Path.

Add the python binding

At last, it is required to install the Python binding:

# Assuming you are in root mxnet source code folder
cd python  
python setup.py install

Validate the installation

>>> import mxnet as mx
>>> a = mx.nd.ones((2, 3))
>>> b = a * 2 + 1
>>> b.asnumpy()
array([[ 3.,  3.,  3.],[ 3.,  3.,  3.]], dtype=float32)  <--- expected Output

Troubleshooting

Specified module could not be found

If importing the library in python throws an error:

>>> import mxnet
OSError: [WinError 126] The specified module could not be found

Probably one of the dependent libraries is not within your Path. Check using the CMD, that all of the following DLLs can be found:

  • mkldnn.dll

  • libopenblas.dll

  • opencv_world341.dll

  • mklml.dll

  • KERNEL32.dll

  • VCOMP140.DLL

Use where <dll-name>, e.g. where mkldnn.dll. If it is within the path, it should show its path, e.g.:

C:\bmxnet> where mkldnn.dll
-> C:\bmxnet\build\3rdparty\mkldnn\src\Release\mkldnn.dll

If any DLL cannot be found, search within the folders C:\bmxnet and C:\utils for it and add the folder, where it is located in, to the path. After adding it to the path, it might be necessary to close and reopen the CMD. Recheck to verify that the DLL can now be found.

Compiler is out of heap space

D:\bmxnet\src\operator\tensor\elemwise_binary_broadcast_op_logic.cc : fatal error C1002: compiler is out of heap space in pass 2 [D:\bmxnet\build\mxnet.vcxproj]
cl : Command line error D8040: error creating or communicating with child process [D:\bmxnet\build\mxnet.vcxproj]
    
164 Warning(s)
4 Error(s)

Solution: Rerun with less background processes running. A machine with at least 8 GByte RAM is recommended.