Mac OS Install with GPU support or MKLDNN does not work


#1

Hello,

I have a MacPro 10.13.6 and I am following the instructions at https://mxnet.incubator.apache.org/install/osx_setup.html.
After having performed Prepare Environment for GPU Installation I was able to build libmxnet.so following these instructions:

    git clone --recursive https://github.com/apache/incubator-mxnet ~/mxnet
    cd ~/mxnet
    cp make/osx.mk ./config.mk
    echo "USE_BLAS = openblas" >> ./config.mk
    echo "ADD_CFLAGS += -I/usr/local/opt/openblas/include" >> ./config.mk
    echo "ADD_LDFLAGS += -L/usr/local/opt/openblas/lib" >> ./config.mk
    echo "ADD_LDFLAGS += -L/usr/local/lib/graphviz/" >> ./config.mk
    make -j$(sysctl -n hw.ncpu)

but if I add to my config.mk the options for GPU support:

    echo "USE_CUDA = 1" >> ./config.mk
    echo "USE_CUDA_PATH = /usr/local/cuda" >> ./config.mk
    echo "USE_CUDNN = 1" >> ./config.mk
    make -j$(sysctl -n hw.ncpu)

then nvcc fails with:

nvcc fatal : The version ('10.0') of the host compiler ('Apple clang') is not supported

even though clang from the llvm package is in the path:

which clang
/usr/local/opt/llvm/bin/clang

my config.mk in this case has the following settings:

USE_BLAS = openblas
ADD_CFLAGS += -I/usr/local/opt/openblas/include
ADD_LDFLAGS += -L/usr/local/opt/openblas/lib
ADD_LDFLAGS += -L/usr/local/lib/graphviz/
USE_LAPACK_PATH=/usr/local/opt/lapack/lib/
USE_CUDA = 1
USE_CUDA_PATH = /usr/local/cuda
USE_CUDNN = 1

Am I trying to combine incompatible options?

If I try to build with MKLDNN I get the following problem:

CMake Error at /usr/local/Cellar/cmake/3.12.1/share/cmake/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "/usr/local/opt/llvm/bin/clang++"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /Users/SB/Software/mxnet/3rdparty/mkldnn/build/CMakeFiles/CMakeTmp
    
    Run Build Command:"/usr/bin/make" "cmTC_2a162/fast"
    /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_2a162.dir/build.make CMakeFiles/cmTC_2a162.dir/build
    Building C object CMakeFiles/cmTC_2a162.dir/testCCompiler.c.o
    /usr/local/opt/llvm/bin/clang++    -o CMakeFiles/cmTC_2a162.dir/testCCompiler.c.o   -c /Users/SB/Software/mxnet/3rdparty/mkldnn/build/CMakeFiles/CMakeTmp/testCCompiler.c
    clang-7: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
    /Users/SB/Software/mxnet/3rdparty/mkldnn/build/CMakeFiles/CMakeTmp/testCCompiler.c:2:3: error: "The CMAKE_C_COMPILER is set to a C++ compiler"
    # error "The CMAKE_C_COMPILER is set to a C++ compiler"
      ^
    1 error generated.
    make[2]: *** [CMakeFiles/cmTC_2a162.dir/testCCompiler.c.o] Error 1
    make[1]: *** [cmTC_2a162/fast] Error 2
    
  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:51 (project)

-- Configuring incomplete, errors occurred!

This looks trivial, but a few things (such as forcing -xc for clang++) I tried did not work.

my config.mk in this case has the following settings:

CC=/usr/local/opt/llvm/bin/clang++
CXX=/usr/local/opt/llvm/bin/clang++
USE_OPENCV=1
USE_OPENMP=1
USE_MKLDNN=1
USE_BLAS=apple
USE_PROFILER=1
USE_LAPACK_PATH=/usr/local/opt/lapack/lib/

What are the correct steps to install with MKLDNN?
Also, some indications about the preferred installation options would be appreciated, I had a look at the FAQ but did not seem to find installation questions.

Thanks,

Stefano


#2

Hi Stefano,

For installing mxnet with mkldnn on cpu, have you tried installing with pip? i.e

pip install mxnet-mkl

Also you seem to be trying to install with GPU support on your mac. This won’t work as you need a machine with nvidia gpu and cuda/cudnn libraries installed.


#3

Hi sad,

Thanks for your reply, you are right about the GPU, for some reason I thought I had an NVIDIA GPU but it is not true.

In any case, I think that the compilation for MKLDNN should work.

I am working with R and I have installed now mxnet in R, but the version without MKLDNN. I am not (yet) using Python, so I am not sure whether pip install mxnet-mkl would be useful for me, right?

Thanks,
Stefano


#4

Yes you’re correct. pip install is for the python package not the R package. I had assumed you were using python. Yes the compilation for MKLDNN should work when you build from source as well.