You are here

ARM64 Apple M1Error compiling Rosetta with extras=mpi

9 posts / 0 new
Last post
ARM64 Apple M1Error compiling Rosetta with extras=mpi
#1

I'm trying to build Rosetta-3.13 "rosetta.source.release-334" with the following command:

./scons.py mode=release bin extras=mpi

I have also updated the site.settings file to prepend the mpicxx and mpicc compilers for openmpi installed in my system.

I got the following error:

ld: warning: ignoring file /opt/programs/openmpi/4.1.4/lib/libmpi.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64

.... lots of lines...

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

scons: *** [build/src/release/macos/10.16/64/x86/clang/14.0/mpi/libutility.dylib] Error 1

scons: building terminated because of errors.

I successfully built the same release without extras=mpi. So it looks like the problem is with my openmpi compiler.

I did installed the OpenMPI v.4.1.4 without using homebrew/macports. I downloaded the source binaries from openmpi.org and installed it using the following command:

./configure --prefix=/opt/programs/openmpi/4.1.4 

and used the GCC pre-installed with Xcode (which looks to be a Clang version).

I have no clue on how to troubleshoot this. Don't know if the problem is with any kind of compatibility with my instalation of openmpi and the new Apple M1 chip. Any ideas?

Thanks,

Danilo.

 

Category: 
Post Situation: 
Fri, 2023-01-27 13:46
dfcoelho

An uptade about this.

I recompiled the OpenMPI with the following command, to ensure compatibility with Apple M1:

./configure --prefix=/opt/programs/openmpi/4.1.4 --build=arm64-apple-darwin21.6.0

After make install, I tried to build rosetta-3.13 "rosetta.source.release-334" with the following command, also to try ensuring  proc compatibility:

./scons.py bin mode=release extras=mpi -j8 arch=arm build=apple-darwin21.6.0

 Weirdly I've got the following error:

scons: Reading SConscript files ...
Traceback (most recent call last):
  File "/opt/programs/rosetta/3.13/rosetta.source.release-334/main/source/SConstruct", line 183, in main
    build = SConscript("tools/build/setup.py")
  File "/opt/programs/rosetta/3.13/rosetta.source.release-334/main/source/external/scons-local/scons-local-3.0.4/SCons/Script/SConscript.py", line 667, in __call__
    return method(*args, **kw)
  File "/opt/programs/rosetta/3.13/rosetta.source.release-334/main/source/external/scons-local/scons-local-3.0.4/SCons/Script/SConscript.py", line 604, in SConscript
    return _SConscript(self.fs, *files, **subst_kw)
  File "/opt/programs/rosetta/3.13/rosetta.source.release-334/main/source/external/scons-local/scons-local-3.0.4/SCons/Script/SConscript.py", line 285, in _SConscript
    call_stack[-1].globals)
  File "/opt/programs/rosetta/3.13/rosetta.source.release-334/main/source/tools/build/setup.py", line 451, in <module>
    build = setup()
  File "/opt/programs/rosetta/3.13/rosetta.source.release-334/main/source/tools/build/setup.py", line 441, in setup
    build.options_requested, build.options = setup_build_options()
  File "/opt/programs/rosetta/3.13/rosetta.source.release-334/main/source/tools/build/setup.py", line 140, in setup_build_options
    supported, actual.os, requested.arch
  File "/opt/programs/rosetta/3.13/rosetta.source.release-334/main/source/tools/build/setup_platforms.py", line 194, in select_arch
    raise ValueError("Actual processor architecture '%s' does not match requested version '%s'" % (actual, requested))

ValueError: Actual processor architecture 'x86' does not match requested version 'arm'

So it looks like the setup_platforms.py is getting the wrong arch for my system.

Still no success to compile with MPI. Any help?

Wed, 2023-02-01 13:33
dfcoelho

Just to make sure about the arch of my chip, the output for the command uname -a is as follow:

Darwin Kernel Version 21.6.0: Sun Nov  6 23:29:57 PST 2022; root:xnu-8020.240.14~1/RELEASE_ARM64_T8101 arm64

So, indeed the arch is arm64 and not x86 as the Rosetta setup_platforms.py seems to find.

Wed, 2023-02-01 13:18
dfcoelho

To some extent, the important thing is what Python thinks the platform is, rather than the command line.

In particular, setup_platforms.py uses whatever `import platform; platform.processor()` returns (either that or `os.uname()[4]`) -- if the python you're running the Rosetta complilation off of thinks the platform is "x86", then that's probably what the setup_platforms.py is going to go with.

You can try using a different python (one which is arm64 native), or you can try monkey-patching the `_get_arch()` function in setup_platforms.py to just return `arm` regardless of what Python thinks the platform is.

Mon, 2023-02-06 14:52
rmoretti

Hi Moretti,

Thanks for your response. I will try your suggestions and let you know if worked or not.

Best,

Danilo.

Thu, 2023-02-09 10:54
dfcoelho

Hi all,

Sorry for the late reply. I had some personal issues but finally I've got time to take a look into this compilation.

What I have found is that in the macOS enviroment there are different Python versions, all of them pre-installed by Apple (I did not install any of them).

The current working version (i.e. the one first defined in the $PATH) is a version of python2/python2.7 which is natively installed in /Library/Frameworks/Python.framework/Versions/2.7/bin and put in my bash env automatically by Apple; my .bash_profile has the following lines, also not included by me:.

# Setting PATH for Python 2.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

This pre-defined is the python that was giving me problem with misleading the actual arch of the chip.

Meanwhile, I also found another python version pre-installed in /usr/bin/python3.

So, I guessed that for some reason the Aple version of python2.7 is not arm64 native, as pointed out by Moretti.

Tried to recompile using python3 and it worked flawlessly. 

 

Thanks for all suport.

 

Best,

Danilo

Sun, 2023-03-05 17:07
dfcoelho

Hello Danilo,

(RESOLVED, SEE POST BELOW)

I'm also attempting to build Rosetta with mpi on an M1 Macbook. I have ran into the same problem as you. I've updated my site.settings to use mpicxx and mpicc. I'm also using the same scons arguments as you. One difference is that I'm using the brew version of mpicxx and mpicc. However, I'm running into the same issue you were having in post #2 of the thread. 

It seems you found a solution by chaning the version of python you were using for one specific for arm. However, I'm not sure how you changed the python version being called. Did you change the python being called in your .bash_profile? Or did you change the executable in the scons.py file? Either way, I'm now running into an issues with package installation:

scons: *** [build/src/release/macos/14.1/64/arm/clang/15.0/mpi/apps/public/AbinitioRelax.o] Error 255
/opt/homebrew/bin/mpicxx -o build/src/release/macos/14.1/64/arm/clang/15.0/mpi/protocols/antibody_legacy/AntibodyClass.os -c -std=c++11 -isystem external/boost_submod/ -isystem external/ -isystem external/include/ -isystem external/dbio/ -isystem external/libxml2/include -isystem external/rdkit -isystem /usr/local/include -mtune=generic -pipe -Qunused-arguments -DUNUSUAL_ALLOCATOR_DECLARATION -ftemplate-depth-256 -stdlib=libstdc++ -W -Wall -Wextra -pedantic -Wno-long-long -Wno-strict-aliasing -mtune=native -stdlib=libc++ -Wno-unused-variable -Wno-implicit-function-declaration -O3 -Wno-unused-variable -Wno-unused-parameter -fPIC -DBOOST_ERROR_CODE_HEADER_ONLY -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS -DBOOST_DISABLE_THREADS -DPTR_STD -DNDEBUG -DUSEMPI -DOMPI_SKIP_MPICXX -Isrc -Iexternal/include -Isrc/platform/macos/64/clang/15.0 -Isrc/platform/macos/64/clang -Isrc/platform/macos/64 -Isrc/platform/macos src/protocols/antibody_legacy/AntibodyClass.cc
scons: *** [build/src/release/macos/14.1/64/arm/clang/15.0/mpi/devel/init.os] Error 255
scons: *** [build/src/release/macos/14.1/64/arm/clang/15.0/mpi/protocols/init/init.os] Error 255
scons: *** [build/src/release/macos/14.1/64/arm/clang/15.0/mpi/protocols/init/register1.os] Error 255
scons: *** [build/src/release/macos/14.1/64/arm/clang/15.0/mpi/protocols/init/register2.os] Error 255
scons: *** [build/src/release/macos/14.1/64/arm/clang/15.0/mpi/protocols/init/register3.os] Error 255
scons: *** [build/src/release/macos/14.1/64/arm/clang/15.0/mpi/protocols/init/register4.os] Error 255
[Austins-MacBook-Pro-2.local:37978] Error: Unable to get the user home directory
[Austins-MacBook-Pro-2.local:37978] Error: Unable to get the user home directory
--------------------------------------------------------------------------
It looks like opal_init failed for some reason; your parallel process is
likely to abort.  There are many reasons that a parallel process can
fail during opal_init; some of which are due to configuration or
environment problems.  This failure appears to be an internal failure;
here's some additional information (which may only be relevant to an
Open MPI developer):

  mca_base_var_init failed
  --> Returned value -1 instead of OPAL_SUCCESS
--------------------------------------------------------------------------
scons: *** [build/src/release/macos/14.1/64/arm/clang/15.0/mpi/protocols/antibody_legacy/AntibodyClass.os] Error 255
scons: building terminated because of errors

 

Any help is appreciated :)

Best,
Austin

Thu, 2024-01-11 11:22
Aseamann

Update,

 

I'm attempting to install openmpi and build it with your arguments. However, I don't have a /opt/programs directory, so I tried install to /opt/local/bin. Whenever I try to build, it doesn't show up in /opt/local/bin.

 

Best,

Austin

Thu, 2024-01-11 10:32
Aseamann

Update,

Was able to resolve, inexperience from me. Here's help for any needing it with the same problem.

For openmpi, brew version also didn't work for me. I downloaded the latest openmpi v4. First uncompress with tar -xzvf. Change into the directory of openmpi. Then use configure command, I used (run "uname -a" for build number):

./configure --prefix=/opt/openmpi/4.1.4 --build=arm64-apple-darwin23.1.0

Then run:

make -j<num processors> all
sudo make install

 

Now with rosetta, modify the first line of scons.py to be (resolve the x86 version issue):

#! /usr/bin/python3

 

Then modify tools/build/site.settings to be (uncomment "cxx" and "cc" lines and point to openmpi executables you just installed):

import os
settings = { 
    "site" : { 
        "prepends" : { 
# Allows detection of the default compiler on your normal path
            "program_path" : os.environ["PATH"].split(":") if "PATH" in os.environ else [], 
# Allows finding system libraries in non-standard locations
            "library_path" : os.environ["LD_LIBRARY_PATH"].split(":") if "LD_LIBRARY_PATH" in os.environ else [], 
# Allows finding system library includes if those includes are in non-standard locations
            "include_path" : os.environ["INCLUDE"].split(":") if "INCLUDE" in os.environ else [], 
        },  
        "appends" : { 
        },  
        "overrides" : { 
## Uncomment the following line if your compiler need additional environment variables to function (e.g. license key locations)
#            "ENV" : os.environ,

## Uncomment (and adjust) the following lines if you wish to explicitly specify the path to a compiler which isn't the default compiler
            "cxx" : "/opt/openmpi/4.1.4/bin/mpicxx", # or clang++ or mpiCC or icpc, etc. -- The C++ compiler.
            "cc"  : "/opt/openmpi/4.1.4/bin/mpicc", # or clang or mpicc or icc, etc. -- The plain C compiler.
        },  
        "removes" : { 
        },  
    },  
}

I then ran:

./scons.py bin mode=release extras=mpi -j8 arch=arm build=apple-darwin23.1.0

 

Best,

Austin

Thu, 2024-01-11 11:31
Aseamann