[gmx-users] [gmx-developers] Problem in compiling Gromacs 4.6.1 with GPU on MAC OS X

Anders Gabrielsson andgab at kth.se
Thu Mar 27 16:16:51 CET 2014


It not clear to me what compiler was used by the poster, but in my experience nvcc works fine using gcc 4.7 (from eg macports).
Unless one runs a mac with both AVX and a CUDA capabilities, one is probably better off with something supporting OpenMP anyway.
> CC=/opt/local/bin/gcc-mp-4.7 CXX=/opt/local/bin/g++-mp-4.7 cmake ../gromacs-4.6 && make mdrun
This implicitly also sets CUDA_HOST_COMPILER to CC (ie gcc).
I'm not sure either what complications adding MPI to the mix will have if any, but perhaps OpenMP or possibly thread-MPI will suffice running on an imac?

Playing it by the book and using clang for the CUDA stuff, follow Szilards advice:
> CC=/opt/local/bin/gcc-mp-4.7 CXX=/opt/local/bin/g++-mp-4.7 cmake ../gromacs-4.6 -DCUDA_HOST_COMPILER=/usr/bin/clang -DCUDA_PROPAGATE_HOST_FLAGS=OFF && make mdrun


There is some weird behaviour with the default cmake settings generated for my system, with compilation again fails with the "-dumpspecs" error.
Setting CUDA_PROPAGATE_HOST_FLAGS doesn't seem to help, but I find that explicitly setting CC (or CUDA_HOST_COMPILER) does.
That is:
fail> cmake ../gromacs-4.6 && make mdrun
fail> cmake ../gromacs-4.6 -DCUDA_PROPAGATE_HOST_FLAGS=OFF && make mdrun
good> CC=/usr/bin/clang CXX/usr/bin/clang++ cmake ../gromacs-4.6 && make mdrun
good> cmake ../gromacs-4.6 -DCUDA_HOST_COMPILER=/usr/bin/clang && make mdrun 

Here, without setting CC cmake picks up /usr/bin/cc which points to the same clang(s) as above.
AFAIK, This is with latest-and-greatest of everything: OS X, Xcode/Apple-clang and CUDA. (also GROMACS of course!) ;)

Happy compiling!
Anders


On 26 Mar 2014, at 15:09, Szilárd Páll <pall.szilard at gmail.com> wrote:

> On OS X the CUDA compiler only supports the official OS X toolchain,
> Xcode. Hence you'll have to use as CUDA_HOST_COMPILER either
> gcc(-llvm) or clang from Xcode. NVIDIA actually has pretty decent docs
> on this:
> http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-mac-os-x/
> 
> The forwarded error was caused by the fact that nvcc uses clang as a
> host-compiler while the standard C/C++ compiler you used is probably
> gcc. Hence, as the gcc C++ compiler flags are propagated to clang and
> this chokes on it. To work around this issue you can:
> - use clang as your C/C++ compiler (but this will leave you without OpenMP) or
> - set CUDA_PROPAGATE_HOST_FLAGS=OFF.
> 
> Cheers,
> --
> Szilárd
> 
> 
> On Wed, Mar 26, 2014 at 11:10 AM, Mark Abraham <mark.j.abraham at gmail.com> wrote:
>> On Wed, Mar 26, 2014 at 12:14 AM, xraynano <mancini at anl.gov> wrote:
>> 
>>> We have had a similar problem as described below. We have tried various
>>> work
>>> arounds that force use of clang correctly with CUDA, or that try to
>>> substitute gcc47 for clang. Then, we can get everything to compile, but
>>> when
>>> trying to run anything in the final installation, it fails with the error:
>>> Malformed Mach-o file
>>> 
>> 
>> I haven't the faintest idea what a Mach-o file is.
>> 
>> Since you can get things to compile, you no longer have any problems
>> related to the email you forwarded below. Why did you want to ask me to
>> spend my time reading that?
>> 
>> 
>>> One would think someone by now would have figured out how to get the GPU
>>> version of GROMACS to properly compile for current Mac OSX. We are running
>>> 10.9.2 on a 12 core with Geforce 680 GPU.
>>> 
>> 
>> Maybe they have, and haven't shared it. Asking people if they have solved
>> it might get a more useful response than expressing frustration that they
>> haven't shared it yet ;-)
>> 
>> On Mac, you need a CUDA-compatible compiler that can compile correct SIMD
>> intrinsics (ie. can use a functioning assembler), and preferably support
>> OpenMP. That's an extremely small set, and I don't even know if it is
>> non-zero. You can make do with something CUDA-compatible without SIMD or
>> OpenMP support, so long as the assembler works - there's various
>> discussions on http://redmine.gromacs.org about known problems.
>> 
>> Mark
>> 
>> salehi wrote
>>>> I was trying to install gromacs 4.6.1 with CUDA and have a weird problem.
>>>> My system is as the following
>>>> new iMAC OS x 10.8.3
>>>> GPU : FTX 650 M 512 MB
>>>> I also installed the open-mpi libraries into the /usr/local/lib folder
>>>> before installation. I have got to say I'm by no means a UNIX expert.
>>>> although I have installed gromacs 4.6.1 with float double and mpi options
>>>> but they were all without GPU options. SO when I started installing 4.6.1
>>>> version with GPU I ran into problems. So I figured it has got to have sth
>>>> to do with the GPU! I don't know what environment variables I needed have
>>>> changed before installation with CMAKE, So I would appreciate it if the
>>>> experts here help me out.
>>>> 
>>>> Firstly, I have installed FFTW3.3.3 with these options:
>>>> 
>>>> ./configure --prefix /usr/local/fftw3 --enable-sse2 --enable-float
>>>> --enable-shared
>>>> make && make install
>>>> 
>>>> so the fftw3 installation folder is /usr/local/fftw3.
>>>> my cuda source directory is located at :  /usr/local/cuda
>>>> and for the cmake options to install the gromacs.Then,
>>>> in the build folder within the gromacs root folder
>>>> cmake -DGMX_FFT_LIBRARY=fftw3
>>>> -DFFTW_LIBRARY='/usr/local/fftw3/lib/libfftw3f.a'
>>>> -DFFTW_INCLUDE_DIR='/usr/local/fftw3/include/' -DGMX_GPU=ON
>>>> -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda
>>>> -DCMAKE_INSTALL_PREFIX=/usr/local/gromacs-4.6.1 ../
>>>> 
>>>> First of all I get the error which says the libfftw3f can not be found.
>>>> The following is my fftw3 installation folder :
>>>> drwxr-xr-x  3 root      102 26 Apr 22:04 pkgconfig
>>>> -rwxr-xr-x  1 root      899 26 Apr 22:04 libfftw3f.la
>>>> -rw-r--r--  1 root  2421656 26 Apr 22:04 libfftw3f.a
>>>> 
>>>> As you can see the file libfftw3f.a is in the folder I have netered in
>>> the
>>>> cmake options. I don't know if there is any CMAKE variables I needed have
>>>> changed here, So I worked around that  by copying the contents of the
>>>> fftw3/lib folder to the usr/local/lib and since cmake looked into that
>>>> folder it found the fftw file and thus ignored my manual addresses for
>>>> fftw library. This time, the cmake command with the same options as above
>>>> ran successfully. However when I run the make I get:
>>>> sudo make
>>>> 
>>>> [  0%] Building NVCC (Device) object
>>>> 
>>> src/gmxlib/gpu_utils/CMakeFiles/gpu_utils.dir//./gpu_utils_generated_memtestG80_core.cu.o
>>>> clang: error: unsupported option '-dumpspecs'
>>>> clang: error: no input files
>>>> CMake Error at gpu_utils_generated_memtestG80_core.cu.o.cmake:206
>>>> (message):
>>>>  Error generating
>>>> 
>>>> 
>>> /Users/salehi/Downloads/gromacs-4.6.1/build/src/gmxlib/gpu_utils/CMakeFiles/gpu_utils.dir//./gpu_utils_generated_memtestG80_core.cu.o
>>>> 
>>>> 
>>>> make[2]: ***
>>>> 
>>> [src/gmxlib/gpu_utils/CMakeFiles/gpu_utils.dir/./gpu_utils_generated_memtestG80_core.cu.o]
>>>> Error 1
>>>> make[1]: *** [src/gmxlib/gpu_utils/CMakeFiles/gpu_utils.dir/all] Error 2
>>>> make: *** [all] Error 2
>>>> 
>>>> 
>>>> I don't know if there is anything wrong with the installation of CUDA but
>>>> I could confirm that all the files that needed be there were there after
>>>> following CUDA's own web site.
>>>> Thank you so much in advance.
>>> 
>>> 
>>> 
>>> --
>>> View this message in context:
>>> http://gromacs.5086.x6.nabble.com/Problem-in-compiling-Gromacs-4-6-1-with-GPU-on-MAC-OS-X-tp5008204p5015382.html
>>> Sent from the GROMACS Developers Forum mailing list archive at Nabble.com.
>>> --
>>> Gromacs Developers mailing list
>>> 
>>> * Please search the archive at
>>> http://www.gromacs.org/Support/Mailing_Lists/GMX-developers_List before
>>> posting!
>>> 
>>> * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>>> 
>>> * For (un)subscribe requests visit
>>> https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developersor send a mail to
>>> gmx-developers-request at gromacs.org.
>>> 
>> --
>> Gromacs Users mailing list
>> 
>> * Please search the archive at http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List before posting!
>> 
>> * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>> 
>> * For (un)subscribe requests visit
>> https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users or send a mail to gmx-users-request at gromacs.org.
> -- 
> Gromacs Users mailing list
> 
> * Please search the archive at http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List before posting!
> 
> * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
> 
> * For (un)subscribe requests visit
> https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users or send a mail to gmx-users-request at gromacs.org.



More information about the gromacs.org_gmx-users mailing list