Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simsopt fails to run on mac M3 with hardware error - illegal instruction: 4 #386

Closed
salomon73 opened this issue Dec 20, 2023 · 1 comment

Comments

@salomon73
Copy link

salomon73 commented Dec 20, 2023

Hi,

I managed to install simsopt on my laptop, a macbook with apple silicon M3 processor.
I am using conda, installed from brew, and updated to the latest version. I followed M1/M2 installation, and in particular the conda toolchain only installation process.

I bypassed the difficulty to install f90wrap with --no-build-isolation by using the conda-forge channel. The code builds after installing a few additional packages.

However, when trying to any simsopt example script, every single step involving
from simsopt import <module_name> fails with the following hardware error: illegal instruction: 4.

Here is what I tried to solve the issue:

  • Created a conda virtual env with osx-64 architecture. The default setting on silicon mac is set on osx-arm, although apple provides us with an emulator called Rosetta to run osx-64 packages or apps on arm64 architecture. I installed all packages from conda-forge with this architecture, and built simsopt this way as well. Building works but execution fails. In this configuration:
    arch -> arm64 uname -m -> arm64
  • Tried the same without the osx-64 conda env, running everything from terminal opened with Rosetta. In this configuration:
    arch -> i386 uname -m -> x86_64
    Simsopt builds the same way but I get the same error when executing scripts, when trying to import scripts. From what I have understood, this same kind of issue has been encountered with packages like tensorflow, for many people.
    I don't know how to solve that bug.

Some additional informations:

  • I created a specific simsopt environment using conda env, not virtualenv. All packages installed in the environment have been installed using conda install through the conda-forge channel, except a few ones installed via pip install --no-build isolation.

  • Building simsopt initially failed as pybind11 was missing. Installing pybind11 with conda-forge gave this error:
    `Could not find a package configuration file provided by pybind11 with any
    of the following names:

    pybind11Config.cmake
    pybind11-config.cmake
    `

I solved is using pip install --no-build-isolation pybind11[global].

Let me know if any additional information is requested.

Thank you.

@salomon73 salomon73 changed the title Simsopt installation fails on mac M3 - building f90wrap Simsopt fails to run on mac M3 with hardware error - illegal instruction: 4 Dec 22, 2023
@salomon73
Copy link
Author

salomon73 commented Jan 14, 2024

To use some packages I installed that are native for Intel and haven't been bridged to Apple silicon, I used my terminal with the Rosetta II emulator when I installed simsopt. The code as then built for arch x86_64, and failed to run on arm64.
This might be helpful if people encounter the same issue: when building the code, make sure that Rosetta is disabled. A quick verification:


uname -m 
arm64

Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant