I am attempting to install Torch (with CUDA support) on a MacBook Pro with an NVIDIA GeForce graphics card running OS X 10.12 by following the installation instructions.
I'm using CUDA 8.0. Although the CUDA system requirements do not list OS X 10.12 and Apple LLVM 8 as supported, the CUDA download page has a link for downloading OS X 10.12 and Apple LLVM 8 compatible CUDA.
The default settings of the torch install script specifies the clang compiler, and finds
-- The C compiler identification is AppleClang 8.0.0.8000042
-- The CXX compiler identification is AppleClang 8.0.0.8000042
It runs through several installation tasks without problems but then repeatedly tries and fails to find OpenMP
-- Try OpenMP C flag = [-fopenmp=libomp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [ ]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-fopenmp]
... (attempt with many other flags) ...
-- Could NOT find OpenMP (missing: OpenMP_C_FLAGS OpenMP_CXX_FLAGS)
Quotes from the OpenMP website suggest that OpenMP is distributed with clang (more on that below). I couldn't find any authoritative sources about whether or not OpenMP is included with Apple LLVM as well. Several answers suggests that it is not, and that the two are incompatible. So I decided to play it safe and attempt to compile with llvm-clang instead.
LLVM-Clang
With the release of Clang 3.8.0, OpenMP 3.1 support is enabled in Clang by default, and the OpenMP runtime is therefore built as a normal part of the Clang build, and distributed with the binary distributions.
I used homebrew to install llvm and changed the following lines in the torch install script
# If we're on OS X, use clang
if [[ `uname` == "Darwin" ]]; then
# make sure that we build with Clang. CUDA's compiler nvcc
# does not play nice with any recent GCC version.
export CC=/usr/local/opt/llvm/bin/clang
export CXX=/usr/local/opt/llvm/bin/clang++
fi
The correct compiler is found
-- The C compiler identification is Clang 3.9.1
-- The CXX compiler identification is Clang 3.9.1
But I still get the error
-- Could NOT find OpenMP (missing: OpenMP_C_FLAGS OpenMP_CXX_FLAGS)
Suggesting that either I have not correctly configured the compiler, or that my reading of the OpenMP website was incorrect.
Additionally, I assumed that because Apple LLVM is supported, other LLVM distributions would also be supported. However, the script throws an another error
nvcc fatal : The version ('30901') of the host compiler ('clang') is not supported
Which suggests that I cannot use this compiler regardless of OpenMP support.
GCC
Finally, I tried using a gcc compiler despite the warning in the torch install script, and it not being on the CUDA supported compilers list.
# If we're on OS X, use clang
if [[ `uname` == "Darwin" ]]; then
# make sure that we build with Clang. CUDA's compiler nvcc
# does not play nice with any recent GCC version.
export CC=/usr/local/opt/gcc/bin/gcc-6
export CXX=/usr/local/opt/gcc/bin/g++-6
fi
The compiler is correctly discovered
-- The C compiler identification is GNU 6.2.0
-- The CXX compiler identification is GNU 6.2.0
And the OpenMP library is also correctly found
-- Try OpenMP C flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Try OpenMP CXX flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Found OpenMP: -fopenmp
-- Compiling with OpenMP support
This shows that the torch install script is capable of detecting OpenMP if it is correctly configured with the compiler.
But as suggested by the comment, CUDA throws an error
nvcc fatal : GNU C/C++ compiler is no longer supported as a host compiler on Mac OS X.
So I cannot simply solve my problem by using the gcc compiler.
Question
What compiler can I use to install torch which supports OpenMP and nvcc?
If the answer is one of the compilers which I have already tried, how can I modify the install script or my compiler configuration to make it work?