hiddenSymmetries/simsopt

Illegal instruction and ImportError

evantoler opened this issue · 5 comments

I am unable to run most tests and examples on a fresh installation in a conda environment.

To reproduce:

conda create -n simsoptenv python=3.8
conda activate simsoptenv
pip install simsopt[MPI,SPEC]

# clone repo for tests & examples
git clone https://github.com/hiddenSymmetries/simsopt.git
cd simsopt/examples/1_Simple

python just_a_quadratic.py

After the optimization finishes, I get the message Illegal instruction (core dumped). The same message causes python minimize_curve_length.py to fail.

I also cannot run (among others) the tests test_finitebuild.py in simsopt/tests/geo.

The error from test_finitebuild.py is:

Traceback (most recent call last):
  File "test_finitebuild.py", line 2, in <module>
    from .surface_test_helpers import get_surface, get_exact_surface
ImportError: attempted relative import with no known parent package

Appreciative thanks in advance for advice or insights!

My understanding is that Illegal instruction means the pre-compiled binary wheel on pip was compiled for a different architecture than what you are running on. What architecture you are on? A workaround is probably to build from source, e.g. pip install -e . from the repository you cloned. @mbkumar is the expert on building and may have other suggestions.

For the ImportError, I see the same error if I try to run python -m unittest test_finitebuild.py in the directory simsopt/tests/geo/. But we usually run the tests from one directory up, i.e. go to the directory simsopt/tests/ and run python -m unittest geo/test_finitebuild.py, in which case the import works on my end. Perhaps we could modify the import so it works also when called from other directories...

Can you please give the specs for the machine you are working on?

Thanks for the info! Here is the architecture I am running on:

CPU: 2X Intel Xeon CPU E5-2650 0 @ 2.00GHz (8core / 16 threads each)
Mem: 64GB
OS: Ubuntu 20.04

I confirm that running python -m unittest -v geo/test_finitebuild.py from the simsopt/tests/ directory resolves the import error. The outputted message is now aligned with the other illegal instructions:

test_biotsavart_with_symmetries (geo.test_finitebuild.MultifilamentTesting)
More involved test that checks whether the multifilament code interacts ... Illegal instruction (core dumped)

Xeon E5-2650 was launched in 2012 and was discontinued in 2015. Simsopt accommodates a lot of old hardware, but this CPU might have slipped through the cracks. It does not make sense for us to make changes for this particular CPU. I recommend you do a local build.

Try first with pip install -v -e .[MPI,SPEC] within the cloned simsopt folder. Since you are using Ubuntu, you can follow the steps used in our CI builds if you run into any difficulties. Please refer to the link below.
https://github.com/hiddenSymmetries/simsopt/blob/master/.github/workflows/ci.yml

Thanks for the help! I switched to an architecture with newer CPUs and was able to install there. I'm marking this issue as resolved.