Comments (5)
Ok, so I assume this is resolved (except maybe improved installation instructions)?
from cpymad.
Hey,
I followed the new installation procedure for Apple Silicon
you mean the one outlined in #114?
I'm not good with Apple, but regarding the last part of the question:
Any chance I can edit those out somewhere and replace them both with -mcpu=apple-m1 as I was able to do when building MAD-X?
You can try simply invoking the compiler manually, just copy the whole line and replace what you think needs to be changed. If you succeed in building the .so
file and place in the correct location under build/
as given by the command line above, setup.py
will automatically pick up the file without trying to rebuild (if it's newer than the .c
file and so on). That's also the procedure we're currently using for makig the windows wheels.
I'm currently also working on getting M1 wheels via cross-compilation as recommended in #113.
from cpymad.
I actually followed the instructions listed here:
https://xsuite.readthedocs.io/en/latest/installation.html#install-on-apple-silicon
along with what can be found here:
https://github.com/hibtc/cpymad/blob/master/doc/installation/macos.rst
since the mention of running pip install -U cython wheel setuptools delocate
could not be found at the first link and made one of the scripts look for libmadx.c
- which is not available through git clone
, only libmadx.pyx
can be found.
I tried your suggestion above and ran the compiler manually: I got 6 warning messages related to CYTHON_FALLTHROUGH
and it generated a libmadx.o
file, not libmadx.so
. I moved it into the temporary build/
directory regardless, but upon running setup.py
it still gives me the -march
error message as it seems to not see the file I just built...
from cpymad.
I'm not sure I can help here, however I have succeeded in cross-compiling for M1 now. You may try the M1 wheels that will be arriving shortly with cpymad 1.12.0.
The main thing that needed to be changed with respect to the x86_64 build was to change the relevant argument to
- -DCMAKE_OSX_ARCHITECTURES=x86_64
+ -DCMAKE_OSX_ARCHITECTURES=arm64
in the cmake command. Other than that, make to install a suitable gfortran compiler, set FC
accordingly. In the GitHub Actions cross-compilation environment I also had to setup a bit of environment, but some of these settings may not be necessary for a native build on a well-configured platform:
sudo xcode-select -switch /Applications/Xcode_12.5.1.app
export SDKROOT="$(xcrun --show-sdk-path)"
export ARCHFLAGS="-arch arm64"
export _PYTHON_HOST_PLATFORM="macosx-11.0-arm64"
export MACOSX_DEPLOYMENT_TARGET="11.0"
LIBDIR="path to folder that contains libgfortran.so"
export LDFLAGS="-L$LIBDIR -Wl,-rpath,$LIBDIR"
Some care needs to be taken to use compatible versions of deployment target, xcode version and gfortran.
See also the updated github action starting here:
cpymad/.github/workflows/build.yml
Lines 185 to 223 in c8156cb
I tried your suggestion above and ran the compiler manually: I got 6 warning messages related to
CYTHON_FALLTHROUGH
and it generated alibmadx.o
file, notlibmadx.so
. I moved it into the temporarybuild/
directory regardless, but upon runningsetup.py
it still gives me the-march
error message as it seems to not see the file I just built...
If you take the compiler line from above and just modify the parts that need changing, it should place the .o file in the correct location (see -o
argument) if it succeeds. An additional link command is required afterwards. Have you tried simply setting architecture to arm64
instead?
Anyway, this route is not really recommended if it can be avoided in any way. Otherwise, see how we do it for the windows build:
cpymad/.github/build/windows/cpymad.sh
Lines 64 to 86 in c8156cb
from cpymad.
Thanks for the detailed reply; turns out that it had to do with the environment the conda
install had set up: when checking on env
, I noticed that I had to manually update the following variables
CFLAGS=-march=core2 -mtune=haswell [...]
CONDA_BACKUP_DEBUG_CFLAGS=-march=core2 -mtune=haswell [...]
DEBUG_CFLAGS=-march=core2 -mtune=haswell [...]
CONDA_BACKUP_CFLAGS=-march=core2 -mtune=haswell [...]
by replacing -march=core2 -mtune=haswell
with -mcpu=apple-m1
. I re-did the full cpymad
install from scratch following your updated commands, and as soon as I changed the 4 CFLAGS
above the installation proceeded flawlessly. Running the test via python -m pytest test
returned 67 passed, 2 xpassed, 4 warnings.
from cpymad.
Related Issues (20)
- Element redefinition and twiss HOT 5
- Add support to release Linux AArch64 wheels HOT 7
- EMIT module output is displayed with "delay" HOT 2
- TWISS: no beta0 found HOT 1
- New functions
- Can't run madx instance. TypeError HOT 5
- Build error on Win10 Anaconda 2022.5 HOT 11
- What is the preferred way to retrieve the command (string) with which an Element was created? HOT 3
- libmadx error installing on M1/M2 Apple Silicon HOT 7
- Pitfalls on compiling libmadx/cpymad on Linux HOT 5
- Proposal: specialize tables HOT 8
- Wheel for M1 apple? HOT 2
- Python 3.11 Wheels HOT 4
- call does not work when double slash is present in file path HOT 2
- access default beam HOT 1
- ValueError: TypeError: write() argument must be str HOT 4
- Python 3.12 wheels HOT 2
- Differences in cpymad `table.twiss` and madx `table(twiss, X, X)` when running `use` HOT 7
- Twiss at certain positions HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpymad.