aaronmarkham commented on a change in pull request #11049: Add linux and macos 
MKLDNN Building Instruction
URL: https://github.com/apache/incubator-mxnet/pull/11049#discussion_r196521793
 
 

 ##########
 File path: MKLDNN_README.md
 ##########
 @@ -0,0 +1,287 @@
+# Build/Install MXNet with MKL-DNN
+
+<h2 id="0">Contents</h2>
+
+* [1. Linux](#1)
+* [2. MacOS](#2)
+* [3. Windows](#3)
+* [4. Verify MXNet with python](#4)
+* [5. Enable MKL BLAS](#5)
+
+<h2 id="1">Linux</h2>
+
+### Prerequisites
+
+```
+apt-get update && apt-get install -y build-essential git libopencv-dev curl 
gcc libopenblas-dev python python-pip python-dev python-opencv graphviz 
python-scipy python-sklearn
+```
+
+### Clone MXNet sources
+
+```
+git clone --recursive https://github.com/apache/incubator-mxnet.git
+cd incubator-mxnet
+git submodule update --recursive --init
+```
+
+### Build MXNet with MKL-DNN
+
+```
+make -j $(nproc) USE_OPENCV=1 USE_MKLDNN=1 USE_BLAS=mkl 
USE_INTEL_PATH=/opt/intel
+```
+
+If you don't have full MKL library installed, you can use OpenBLAS by setting 
`USE_BLAS=openblas`.
+
+<h2 id="2">MacOS</h2>
+
+### Prerequisites
+
+Install the dependencies, required for MXNet, with the following commands:
+
+- [Homebrew](https://brew.sh/)
+- gcc (clang in macOS does not support OpenMP)
+- OpenCV (for computer vision operations)
+
+```
+# Paste this command in Mac terminal to install Homebrew
+/usr/bin/ruby -e "$(curl -fsSL 
https://raw.githubusercontent.com/Homebrew/install/master/install)"
+
+# install dependency
+brew update
+brew install pkg-config
+brew install graphviz
+brew tap homebrew/core
+brew install opencv
+brew tap homebrew/versions
+brew install gcc49
+brew link gcc49
+```
+
+### Enable OpenMP for MacOS
+
+If you want to enable OpenMP for better performance, you should modify these 
two files:
+
+1. Makefile L138:
+
+```
+ifeq ($(USE_OPENMP), 1)
+# ifneq ($(UNAME_S), Darwin)
+    CFLAGS += -fopenmp
+# endif
+endif
+```
+
+2. prepare_mkldnn.sh L96:
+
+```
+CC=gcc-4.9 CXX=g++-4.9 cmake $MKLDNN_ROOTDIR 
-DCMAKE_INSTALL_PREFIX=$MKLDNN_INSTALLDIR -B$MKLDNN_BUILDDIR 
-DARCH_OPT_FLAGS="-mtune=generic" -DWITH_TEST=OFF -DWITH_EXAMPLE=OFF >&2
+```
+
+### Build MXNet with MKL-DNN
+
+```
+make -j $(sysctl -n hw.ncpu) CC=gcc-4.9 CXX=g++-4.9 USE_OPENCV=0 USE_OPENMP=1 
USE_MKLDNN=1 USE_BLAS=apple USE_PROFILER=1
+```
+
+*Note: Temporarily disable OPENCV.*
+
+<h2 id="3">Windows</h2>
+
+We recommend to build and install MXNet yourself using [Microsoft Visual 
Studio 2015](https://www.visualstudio.com/vs/older-downloads/), or you can also 
try experimentally the latest [Microsoft Visual Studio 
2017](https://www.visualstudio.com/downloads/).
+
+**Visual Studio 2015**
+
+To build and install MXNet yourself, you need the following dependencies. 
Install the required dependencies:
+
+1. If [Microsoft Visual Studio 
2015](https://www.visualstudio.com/vs/older-downloads/) is not already 
installed, download and install it. You can download and install the free 
community edition.
+2. Download and Install [CMake](https://cmake.org/) if it is not already 
installed.
+3. Download and install 
[OpenCV](http://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.0.0/opencv-3.0.0.exe/download).
+4. Unzip the OpenCV package.
+5. Set the environment variable ```OpenCV_DIR``` to point to the ```OpenCV 
build directory``` (```C:\opencv\build\x64\vc14``` for example). Also, you need 
to add the OpenCV bin directory (```C:\opencv\build\x64\vc14\bin``` for 
example) to the ``PATH`` variable.
+6. If you have Intel Math Kernel Library (MKL) installed, set ```MKL_ROOT``` 
to point to ```MKL``` directory that contains the ```include``` and ```lib```. 
If you want to use MKL blas, you should set ```-DUSE_BLAS=mkl``` when cmake. 
Typically, you can find the directory in
+```C:\Program Files 
(x86)\IntelSWTools\compilers_and_libraries_2018\windows\mkl```.
+7. If you don't have the Intel Math Kernel Library (MKL) installed, download 
and install 
[OpenBLAS](http://sourceforge.net/projects/openblas/files/v0.2.14/). Note that 
you should also download ```mingw64.dll.zip`` along with openBLAS and add them 
to PATH.
+8. Set the environment variable ```OpenBLAS_HOME``` to point to the 
```OpenBLAS``` directory that contains the ```include``` and ```lib``` 
directories. Typically, you can find the directory in ```C:\Program files 
(x86)\OpenBLAS\```. 
+
+After you have installed all of the required dependencies, build the MXNet 
source code:
+
+1. Download the MXNet source code from 
[GitHub](https://github.com/apache/incubator-mxnet). Don't forget to pull the 
submodules:
 
 Review comment:
   Use `--recursive` to download and initialize the submodules.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to