eric-haibin-lin closed pull request #12724: simplify mac mkldnn build URL: https://github.com/apache/incubator-mxnet/pull/12724
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/MKLDNN_README.md b/MKLDNN_README.md index 43cced49ed0..9da2eee297a 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 a4b41b8d837..620679a44f8 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 53039252888..9355dbed715 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 47f395bccf9..00acdd6458a 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 ---------------------------------------------------------------- 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
