wiki:MacM1Notes

Version 4 (modified by toby, 5 months ago) (diff)

--

Installing a Native "Apple Silicon" GSAS-II Version on MacOS

Conda on M1 Mac

(May 2022) Thanks to Billy Poon, who fixed the conda-forge/wxpython bug, conda can now be used to create a working Python for GSAS-II. Note that these instructions do not provide the subversion (svn) program that is usually needed to install GSAS-II, so until this is addressed, svn must be installed by some other method, such as homebrew (see below).

Short instructions are below:

1) Download the latest version of miniforge or mambaforge (I recommend mambaforge) from https://github.com/conda-forge/miniforge/releases/latest. The file you will want will be named Mambaforge-<version>-MacOSX-arm64.sh (or Miniforge...)

2) Install Python from the downloaded file using a command in a terminal window similar to this:

toby@bht21 % bash ~/Downloads/Mambaforge-4.12.0-0-MacOSX-arm64.sh

(note that your file location and name may vary from this.)

3) The installer will ask you to press Enter or space multiple times to read the license file.

A) You will then need to agree to the terms by typing yes.

B) You will then need to supply a location to install this Python. Enter a name like ~/py39.

C) The installer will ask for permission to add conda into your login environment. I suggest saying no so that this installation cannot interfere with any other installed software, but if you want to use this Python for multiple purposes, you might prefer to answer otherwise.

4) Initialize the Python you have just installed using this command:

source ~/py39/bin/activate

(note that this command will depend on the answer used in 3B above.)

5) Install the other Python packages required by GSAS-II with this command:

conda install python=3.9 wxpython numpy scipy matplotlib pyopengl pillow h5py imageio -c conda-forge

6) Assuming that subversion is installed, install GSAS-II using these four commands:

(base) toby@bht21 ~ % mkdir /tmp/GSASII                          
(base) toby@bht21 ~ % cd /tmp/GSASII   
(base) toby@bht21 GSASII % svn export https://subversion.xray.aps.anl.gov/pyGSAS/install/bootstrap.py .
(base) toby@bht21 GSASII % python bootstrap.py 

Note that if subversion is not installed and in the path, the third command will fail. This is also required for the fourth command.

GSAS-II using Homebrew

(June 2021) After something like 4 months of occasional trial and much error, I was finally able to get GSAS-II to run on a ARM Mac running MacOS 11.2.3. As I write this, Anaconda is not supporting ARM Macs and the wxpython version of miniforge is broken, so I had to install Python and associated packages with homebrew.

Installing Homebrew

See this page. Note that access to a Admin level account is a requirement for this. Use these steps:

  1. Install command line tools. Use command:
    xcode-select --install
    
  2. Log into a admin account (I used su admin in a terminal running as a standard user)
  3. Install homebrew using command:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  1. To add brew to path, use command:
    eval "$(/opt/homebrew/bin/brew shellenv)"
    

Install stuff with brew

Brew is used to install a bunch of things. Here are the commands I used:

brew install svn
brew install python
brew install scipy
brew install wxpython

Install more stuff with pip

python3 -m pip install -U matplotlib
python3 -m pip install -U pyopengl  

Install GSAS-II

These steps are best done from a user account rather than an admin account. You can log out of the admin account or simply close the terminal window used before and open a new one.

eval "$(/opt/homebrew/bin/brew shellenv)"
mkdir ~/GSASII
cd ~/GSASII
curl https://subversion.xray.aps.anl.gov/pyGSAS/install/bootstrap.py -o bootstrap.py
python3 bootstrap.py

Compiling GSAS-II fortran routines

You probably do not need this. There is now a set of M1 (aka ARM, aka Apple Silicon) binaries in

This was fairly hard and I don't know what steps were required in retrospect. Also, it might have been better to use brew install gfortran scons rather than using miniforge to install gfortran. (I downloaded https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh from Miniforge3-MacOSX-arm64 link on https://github.com/conda-forge/miniforge

bash ~/Downloads/Miniforge3-MacOSX-arm64.sh
source /Users/toby/miniforge3/bin/activate
conda create -n buildg10.2 gfortran=10.2 gfortran_impl_osx-arm64=10.2 scons numpy

I installed all of Xcode to get file headers, but that may not have been needed. I had a lot of problems getting gcc to find them, but that should now be changed in Sconstruct

Speed Benchmarks

These comparisons are for two very different powder refinement cycles with a 2.3 Mh quadcore I7 MacBook Pro (early 2020) with a M1 MacBook Pro (late 2020); Both have 16 Gb.

Intel I7 Apple M1 I7:M1 ratio
4 cores 4 performance
& 4 efficiency
6.99 s 3.85 s 1.82
106.9 s 57.34 1.86