-
Notifications
You must be signed in to change notification settings - Fork 49
Mac M1 M2 installation
Find below the simsopt and VMEC
installation instructions from source onto a mac with an M1 chip. The simsopt
installation works as of March 21, 2021 and the VMEC
installation works as of July 11, 2022. Installation with only conda-toolchain works as of Oct 25, 2023 (preferred) on Mac OS Ventura.
Much of this installation is similar to the standard Mac installation instructions, but for completeness the entire instruction set will be included here.
The following instructions for installing simsopt with dependencies obtained from conda work for installing vmec also.
-
Install conda. The installation instructions can be found here.
-
Add conda-forge channel.
conda config --add channels conda-forge
-
Create a conda virtual environment and activate it. Instructions can be found here.
-
Install compilers, netcdf-fortran, openmpi-mpicc, openmpi-mpifort, and openblas (for VMEC2000)
conda install compilers netcdf-fortran openmpi-mpicc openmpi-mpifort openblas scalapack
Restart the terminal after installing the above packages. Also install VMEC build dependencies such as mpi4py, scikit-build, numpy
conda install mpi4py scikit-build numpy
Also install f90wrap dependency meson-python from conda
conda install meson-python
Install f90wrap from pip without build isolation
pip install --no-build-isolation f90wrap
-
Optionally, install VMEC2000 from github.com/hiddensymmetries. Follow the instructions here. Copy cmake/machines/cmake_mac_manual_conda_config.json to cmake_config_file.json. Then install VMEC2000.
-
Install LLVM-OpenMP and other simsopt dependencies from conda before building simsopt
conda install llvm-openmp numpy jax jaxlib scipy Deprecated nptyping monty ruamel.yaml sympy f90nml randomgen pyevtk
If any of the above packages are not installable from conda, install with pip using the command
pip install --no-build-isolation <package name>
. -
Install build dependencies from conda
conda install cmake ninja setuptools_scm
-
Obtain simsopt from github.com/hiddensymmetries.
git clone git@github.com:hiddenSymmetries/simsopt.git
or
git clone https://github.com/hiddenSymmetries/simsopt.git
Switch to the simsopt folder and use pip to install simsopt from source. Make sure to install without build isolation.
cd simsopt pip install --no-build-isolation .
-
Install macports. The installation instructions can be found here.
-
Install openmpi. Multiple versions of openmpi are avaialable. Here openmpi version that matches with clang11 is installed.
sudo port install openmpi-clang11 sudo port select --set mpi openmpi-clang11-fortran
Installation of openmpi-clang11 also install python 3.9. Set this version of python3.9 as default python version.
sudo port select --set python python39 sudo port select --set python3 python39
-
Select the proper
mpi
version:sudo port select --set mpi openmpi-mp-fortran
- Install conda. The installation instructions for doing so can be found [here]{https://docs.conda.io/projects/conda/en/latest/user-guide/install/macos.html}. I used Miniconda, but presumably Anaconda will also work.
Mac Catalina (10.15) comes with python 3.7, which can be accessed with python3 command. But we are using the python3.9 from macports. Assuming you ran step 2 in Macports section
- Create a virtual environment named
simsopt_ve
:conda create -n <path_where_you_want_the_venv>/simsopt_ve
- Activate the virtual environment.
After activating the virtual environment,
conda activate <path_where_you_want_the_venv>/simsopt_ve/bin/activate
(simsopt_ve)
should appear in front of the command prompt.
- Install homebrew by running
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Add homebrew to path:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/agood/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)"
Replacing agood
in the above command with your cobra username.
-
Install
openBLAS
by runningbrew install openblas
-
Set up the
openBLAS
path:export PKG_CONFIG_PATH="/opt/homebrew/opt/openblas/lib/pkgconfig" OPENBLAS="$(brew --prefix openblas)"
-
Clone the
simsopt
directory anywhere in your file system, and navigate to that directorygit clone https://github.com:hiddenSymmetries/simsopt.git cd simsopt
-
In the
CMakeLists.txt
file, replace all instances ofmarch=native
withmpcu=apple-m1
. -
Install
simsopt
by runningOPENBLAS="$(brew --prefix openblas)" pip install -e ".[MPI]"
- Run the following command to set up conda properly, and install the needed packages using conda:
conda config --add channels conda-forge
conda config --set channel_priority strict
conda install mpi4py
conda install -c conda-forge netcdf-fortran
conda install -c conda-forge scalapack
pip install mpi4py scikit-build numpy f90wrap ninja cmake
conda install -c conda-forge gfortran
- Clone the VMEC2000 repository to your system, and navigate to that directory
git clone https://github.com/hiddenSymmetries/VMEC2000
cd VMEC2000
- Navigate to the
VMEC2000
directory, and replace the contents of thecmake_config_file.json
with
{
"cmake_args": [
"-DCMAKE_C_COMPILER=clang",
"-DCMAKE_CXX_COMPILER=clang",
"-DCMAKE_Fortran_COMPILER=mpif90",
"-DNETCDF_INC_PATH=/opt/homebrew/opt/netcdf",
"-DNETCDF_LIB_PATH=/opt/homebrew/opt/netcdf",
"-DNETCDF_I=/opt/local/include/netcdf.inc"]
}
- Install VMEC
python setup.py build_ext
python setup.py install