This is an automated email from the ASF dual-hosted git repository.
haibin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new 5961dce simplify mac mkldnn build (#12724)
5961dce is described below
commit 5961dce0f790a0002de37b4cc19d8167cbaedc82
Author: Alexander Zai <[email protected]>
AuthorDate: Tue Oct 16 09:30:39 2018 -0700
simplify mac mkldnn build (#12724)
* remove guard that prevent omp flag in mac
* udpate doc for mac make build
* update docs
* update readme
* set opencv to 1 in instructions
* remove disable opencv line
* update mac docs
* fix indent
---
MKLDNN_README.md | 23 +++--------------------
Makefile | 4 +---
docs/install/osx_setup.md | 12 +++++++++++-
make/osx.mk | 1 +
4 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/MKLDNN_README.md b/MKLDNN_README.md
index 43cced4..9da2eee 100644
--- a/MKLDNN_README.md
+++ b/MKLDNN_README.md
@@ -45,7 +45,7 @@ If you don't have full
[MKL](https://software.intel.com/en-us/intel-mkl) library
Install the dependencies, required for MXNet, with the following commands:
- [Homebrew](https://brew.sh/)
-- gcc (clang in macOS does not support OpenMP)
+- llvm (clang in macOS does not support OpenMP)
- OpenCV (for computer vision operations)
```
@@ -59,8 +59,7 @@ brew install graphviz
brew tap homebrew/core
brew install opencv
brew tap homebrew/versions
-brew install gcc49
-brew link gcc49 #gcc-5 and gcc-7 also work
+brew install llvm
```
### Clone MXNet sources
@@ -70,28 +69,12 @@ git clone --recursive
https://github.com/apache/incubator-mxnet.git
cd incubator-mxnet
```
-### Enable OpenMP for MacOS
-
-If you want to enable OpenMP for better performance, you should modify the
Makefile in MXNet root dictionary:
-
-Add CFLAGS '-fopenmp' for Darwin.
-
-```
-ifeq ($(USE_OPENMP), 1)
-# ifneq ($(UNAME_S), Darwin)
- CFLAGS += -fopenmp
-# endif
-endif
-```
-
### 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
+LIBRARY_PATH=$(brew --prefix llvm)/lib/ make -j $(sysctl -n hw.ncpu) CC=$(brew
--prefix llvm)/bin/clang++ CXX=$(brew --prefix llvm)/bin/clang++ USE_OPENCV=1
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/).
diff --git a/Makefile b/Makefile
index a4b41b8..620679a 100644
--- a/Makefile
+++ b/Makefile
@@ -145,9 +145,7 @@ else
endif
ifeq ($(USE_OPENMP), 1)
- ifneq ($(UNAME_S), Darwin)
- CFLAGS += -fopenmp
- endif
+ CFLAGS += -fopenmp
endif
ifeq ($(USE_NNPACK), 1)
diff --git a/docs/install/osx_setup.md b/docs/install/osx_setup.md
index 5303925..9355dbe 100644
--- a/docs/install/osx_setup.md
+++ b/docs/install/osx_setup.md
@@ -65,6 +65,10 @@ Install the dependencies, required for MXNet, with the
following commands:
brew install openblas
brew tap homebrew/core
brew install opencv
+
+ # If building with MKLDNN
+ brew install llvm
+
# Get pip
easy_install pip
# For visualization of network graphs
@@ -89,12 +93,18 @@ The file called ```osx.mk``` has the configuration required
for building MXNet o
make -j$(sysctl -n hw.ncpu)
```
+To build with MKLDNN
+
+```bash
+LIBRARY_PATH=$(brew --prefix llvm)/lib/ make -j $(sysctl -n hw.ncpu) CC=$(brew
--prefix llvm)/bin/clang++ CXX=$(brew --prefix llvm)/bin/clang++ USE_OPENCV=1
USE_OPENMP=1 USE_MKLDNN=1 USE_BLAS=apple USE_PROFILER=1
+```
+
If building with ```GPU``` support, add the following configuration to
config.mk and build:
```bash
echo "USE_CUDA = 1" >> ./config.mk
echo "USE_CUDA_PATH = /usr/local/cuda" >> ./config.mk
echo "USE_CUDNN = 1" >> ./config.mk
- make
+ make -j$(sysctl -n hw.ncpu)
```
**Note:** To change build parameters, edit ```config.mk```.
diff --git a/make/osx.mk b/make/osx.mk
index 5653b39..3e2e592 100644
--- a/make/osx.mk
+++ b/make/osx.mk
@@ -77,6 +77,7 @@ USE_CUDNN = 0
USE_OPENCV = 1
# use openmp for parallelization
+# apple-clang by default does not have openmp built-in
USE_OPENMP = 0
# choose the version of blas you want to use