LoginSignup
7
3

AMBER24とAmberTools24のインストール方法

Last updated at Posted at 2022-05-07

※ AMBER20のインストール法はこちら

環境

  • macOS 14.4 (Sonoma), 2.3GHz Intel Core i7, メモリ16GB。M3 Macでも検証。
  • Xcode 15.3 (XCodeは必要) App Storeからインストールしておく。
  • ターミナルからHomebrewをインストールしてある
  • ターミナルからxcode-select --installでCommand Line Toolsをインストールしてある(必要)。
  • LinuxはUbuntu 22.04, Rocky Linux 8で検証。

Note

2024年5月1日にAMBER24とAmbeTools24がリリースされました( http://ambermd.org/GetAmber.php)。近年はAMBER本体が偶数年に2年ごと、AmberToolsは1年ごとにメジャーアップデートしています。解凍したときのディレクトリがともにamber24_srcとなっていますがこれは仕様です。

公式のCMakeを使ったインストール方法は http://ambermd.org/pmwiki/pmwiki.php/Main/CMake-Quick-Start に書かれています。CMakeのオプション一覧は http://ambermd.org/pmwiki/pmwiki.php/Main/CMake-Common-Options を確認してください。

macOSへのインストール方法

公式からソースコードのAmber24.tar.bz2とAmberTools24.tar.bz2を入手していることが前提です。

以下の処理を先にしておく必要があります。

  • XcodeXcode command line developer toolsをインストールしておく。XcodeはApp storeからダウンロードします。Xcode command line developer toolsはターミナルからxcode-select --installを入力し、その後指示に従います。さらにターミナルからsudo xcodebuild -license acceptも追加で入力が必要。

以下インストール手順です。

# macOSのHomebrewで必要なソフトウェアをインストールしておく。
brew install cmake gcc wget open-mpi boost
# HomebrewのPrefixを設定
HOMEBREW_PREFIX=`brew --prefix`
# HOMEBREW_PREFIXの値は、Intel Macならば/usr/local, M1 Macならば/opt/homebrewとなる。
# Homebrewのgfortran-13をgfortranとしてシンボリックリンクを貼っておく必要がある。
ln -sf HOMEBREWPREFIX/bin/gfortran−13{HOMEBREW_PREFIX}/bin/gfortran
# ダウンロードしてきたソースコードをtar jxvfで解凍する
tar jxvf AmberTools24.tar.bz2 ; tar jxvf Amber24.tar.bz2
cd amber24_src
# updateを実行する
./update_amber --update
# cmake用のbuildディレクトリに入る
cd build
###############################
# ここが最重要の設定。-DCMAKE_INSTALL_PREFIXにインストール先ディレクトリを指定する
# 下の例はホームディレクトリ以下のapps/amber24にインストールする設定。
# MPIはONにする。Macの場合、COMPILERはCLANGを指定する。
# -DBoost_DIR=${HOMEBREW_PREFIX}/opt/boostと-DFORCE_EXTERNAL_LIBS="boost"とすることで、
# Homebrewで入れたBoostを使うようになる。なぜか必須のようだ。
# 2024年5月2日時点で、macOS Sonoma 14.4とXCode 15.3とOpenMPIを使っている場合、gfortranのMPIのLinker flagsに問題があるようで、
# -DMPI_Fortran_LINK_FLAGS=-Wl,-ld_classicをつける必要がある。
# Apple M3 macの場合、QUICKビルド時にエラーが起きるので、-DBUILD_QUICK=FALSEを追加する。(QUICKはM3 Macで動かすものではないので不要)
###############################
HOMEBREW_PREFIX=`brew --prefix`
AMBER_PREFIX=$(dirname $(dirname `pwd`))
cmake $AMBER_PREFIX/amber24_src \
    -DCMAKE_INSTALL_PREFIX=${HOME}/apps/amber24 -DCOMPILER=CLANG -DBLA_VENDOR=Apple \
    -DBoost_DIR=${HOMEBREW_PREFIX}/opt/boost -DFORCE_EXTERNAL_LIBS="boost" \
    -DMPI=TRUE -DBUILD_GUI=FALSE -DCUDA=FALSE -DINSTALL_TESTS=TRUE -DMPI_Fortran_LINK_FLAGS=-Wl,-ld_classic \
    -DDOWNLOAD_MINICONDA=TRUE -LA 2>&1 | tee cmake.log
# Intel Macの人向け:mpi4pyをどうしても入れたい人へ
# makeが終わってからでも良い
./CMakeFiles/miniconda/install/bin/python3.11 -m pip install mpi4py
# Configureが正常終了していることを確認したらmakeとインストールを実行する
make -j8 install

cmakeの終わり頃には結果一覧が表示されますので、適切な値になっているか確認してみましょう。

If you can't see the following build report, then you need to turn off COLOR_CMAKE_MESSAGES
-- **************************************************************************
--                               Build Report
--                              Compiler Flags:
-- C No-Opt:           -Wall -Wno-unused-function -O0
-- C Optimized:        -Wall -Wno-unused-function -O3 -mtune=native
--
-- CXX No-Opt:         -Wall -Wno-unused-function -stdlib=libc++ -O0
-- CXX Optimized:      -Wall -Wno-unused-function -stdlib=libc++ -O3 -mtune=native
--
-- Fortran No-Opt:     -Wall -Wno-tabs -Wno-unused-function -ffree-line-length-none -Wno-unused-dummy-argument -Wno-unused-variable -fallow-argument-mismatch -fno-inline-arg-packing -O0
-- Fortran Optimized:  -Wall -Wno-tabs -Wno-unused-function -ffree-line-length-none -Wno-unused-dummy-argument -Wno-unused-variable -fallow-argument-mismatch -fno-inline-arg-packing -O3 -mtune=native
--
--                           3rd Party Libraries
-- ---building bundled: -----------------------------------------------------
-- ucpp - used as a preprocessor for the NAB compiler
-- netcdf-fortran - for creating trajectory data files from Fortran
-- xblas - used for high-precision linear algebra calculations
-- kmmd - Machine-learning molecular dynamics
-- tng_io - enables GROMACS tng trajectory input in cpptraj
-- nlopt - used to perform nonlinear optimizations
-- mpi4py - MPI support library for MMPBSA.py
-- pnetcdf - used by cpptraj for parallel trajectory output
-- perlmol - chemistry library used by FEW
-- ---using installed: ------------------------------------------------------
-- blas - for fundamental linear algebra calculations
-- lapack - for fundamental linear algebra calculations
-- arpack - for fundamental linear algebra calculations
-- netcdf - for creating trajectory data files
-- fftw - used to do Fourier transforms very quickly
-- readline - enables an interactive terminal in cpptraj
-- zlib - for various compression and decompression tasks
-- libbz2 - for bzip2 compression in cpptraj
-- libm - for fundamental math routines if they are not contained in the C library
-- boost - C++ support library
-- ---disabled: ------------------------------------------------
-- c9x-complex - used as a support library on systems that do not have C99 complex.h support
-- protobuf - protocol buffers library, used for communication with external software in QM/MM
-- lio - used by Sander to run certain QM routines on the GPU
-- apbs - used by Sander as an alternate Poisson-Boltzmann equation solver
-- pupil - used by Sander as an alternate user interface
-- plumed - used as an alternate MD backend for Sander
-- mkl - alternate implementation of lapack and blas that is tuned for speed
-- mbx - computes energies and forces for pmemd with the MB-pol model
-- libtorch - enables libtorch C++ library for tensor computation and dynamic neural networks

--                                Features:
-- MPI:                               ON
-- MVAPICH2-GDR for GPU-GPU comm.:    OFF
-- OpenMP:                            OFF
-- CUDA:                              OFF
-- Build Shared Libraries:            ON
-- Build GUI Interfaces:              OFF
-- Build Python Programs:             ON
--  -Python Interpreter:              Internal Miniconda (version 3.12)
-- Build Perl Programs:               ON
-- Build configuration:               RELEASE
-- Target Processor:                  x86_64
-- Build Documentation:               ON
-- Sander Variants:                   normal LES API LES-API MPI LES-MPI QUICK-MPI
-- Install location:                  /Users/bilab/apps/amber24/
-- Installation of Tests:             ON

--                               Compilers:
--         C: AppleClang 15.0.0.15000309 (/usr/bin/clang)
--       CXX: AppleClang 15.0.0.15000309 (/usr/bin/clang++)
--   Fortran: GNU 13.2.0 (/usr/local/bin/gfortran)

--                              Building Tools:
-- addles ambpdb antechamber cew cifparse cphstats cpptraj emil etc fe-toolkit few gbnsr6 gem.pmemd kmmd leap lib mdgx mm_pbsa mmpbsa_py moft nabc ndiff-2.00 nfe-umbrella-slice nmode nmr_aux packmol_memgen paramfit parmed pbsa pdb4amber pmemd pymsmt pysander pytraj quick reduce rism sander saxs sebomd sff sqm xray xtalutil

--                            NOT Building Tools:
-- tcpb-cpp - BUILD_TCPB is not enabled
-- tcpb-cpp/pytcpb - BUILD_TCPB is not enabled
-- reaxff_puremd - BUILD_REAXFF_PUREMD is not enabled
-- gpu_utils - Requires CUDA
-- **************************************************************************
-- Environment resource files are provided to set the proper environment
-- variables to use AMBER and AmberTools. This is required to run any Python
-- programs (like MMPBSA.py, ParmEd, MCPB.py, and pytraj)
--
-- If you use a Bourne shell (e.g., bash, sh, zsh, etc.), source the
-- /Users/bilab/apps/amber24//amber.sh file in your shell. Consider adding the line
--   test -f /Users/bilab/apps/amber24//amber.sh && source /Users/bilab/apps/amber24//amber.sh
-- to your startup file (e.g., ~/.bashrc)
--
-- If you use a C shell (e.g., csh, tcsh), source the
-- /Users/bilab/apps/amber24//amber.csh file in your shell. Consider adding the line
--   test -f /Users/bilab/apps/amber24//amber.csh && source /Users/bilab/apps/amber24//amber.csh
-- to your startup file (e.g., ~/.cshrc)
--
-- NOTE: MacOS users might need to source it in ~/.bash_profile file

-- Amber will be installed to /Users/bilab/apps/amber24/
-- Configuring done (352.7s)
-- Generating done (2.0s)

上の例は正しくMPI設定がON, GUI設定がOFFになっていることがわかります。これはcmake時に-DMPI=TRUE -DBUILD_GUI=FALSEにした設定と対応しています。

コンパイラ設定も確認してみます。

--                               Compilers:
--         C: AppleClang 15.0.0.15000309 (/usr/bin/clang)
--       CXX: AppleClang 15.0.0.15000309 (/usr/bin/clang++)
--   Fortran: GNU 13.2.0 (/usr/local/bin/gfortran)

AmberTools24ではAppleClangとHomebrewでインストールしたOpenMPIによる並列化処理が問題なく行われるようになっています。ただし、FortranだけはAppleClangにないので、これはbrew install gccで外部からインストールする必要がありました。

インストールが終わったら、AMBERのプログラムコマンドをいつでも使えるようにするために、~/.bash_profileecho $SHELLと打ってみて最後がbashの場合)または~/.zshrcecho $SHELLと打ってみて最後がzshの場合。macOS Catalinaを使っているヒトはzshがデフォルトになっているはず)のどちらかのファイルに(なければ作成する)、以下のように書き込みます。

# for AMBER 24
test -f ${HOME}/apps/amber24/amber.sh && source ${HOME}/apps/amber24/amber.sh

これでターミナルの起動時にAMBER24とAmberTools24のコマンドがいつでも使えるようになっているはずです。ターミナルを再起動してみたときにecho $AMBERHOMEと打ってみてAMBERをインストールしたパス(/Users/username/apps/amber24みたいな感じ)が表示されれば成功です。

mpi4pyがインストールできない問題の解決法

(2023年7月31日追記)長らくここに書くのを忘れていましたが、mpi4pyはインストールに失敗する事が多く、失敗してもそのままスルーされる事が多いため、MMPBSA.py.MPIが動作しないことが多いです。この解決方法は、インストールのためのソースディレクトリのamber24_src/build/CMakeFiles/miniconda/install/compiler_compatにおいて、

total 4
-rw-rw-r-- 2 z00000r gr0001 173 Apr 25 16:07 README
lrwxrwxrwx 1 z00000r gr0001 32 Aug 22 16:14 ld -> ../bin/x86_64-conda-linux-gnu-ld

という2つのファイルがあるのですが、このうちldというシンボリックリンクを削除してシステムのものにシンボリックリンクを張り直します。

rm -f ld
ln -s /usr/bin/ld ld

そして、その状態で

amber.python -m pip install mpi4py

(AMBERのpythonのpipを用いてmpi4pyをインストールするコマンド)を実行します。

$ amber.python -m pip install mpi4py
Collecting mpi4py
  Downloading mpi4py-3.1.5.tar.gz (2.5 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.5/2.5 MB 596.8 kB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: mpi4py
  Building wheel for mpi4py (pyproject.toml) ... done
  Created wheel for mpi4py: filename=mpi4py-3.1.5-cp311-cp311-linux_x86_64.whl size=623445 sha256=ac434ad8241c24ee33e29ff1a6bae1355b47b25ce58099e704bd053612f45733
  Stored in directory: /work/04/gw43/w43001/.cache/pip/wheels/b4/36/dc/392c299a27e4f93c9fe3f215cfe71245415c278bebfefc5414
Successfully built mpi4py
Installing collected packages: mpi4py
Successfully installed mpi4py-3.1.5

そしてうまくmpi4pyのインストールが終わったら

ln -sf ../bin/x86_64-conda-linux-gnu-ld

で元通りにすることで、MMPBSA.py.MPIが動作するようになります。これはUbuntu 22.04の場合も同様です。

Ubuntu 22.04の場合

aptで依存パッケージを入れます。

sudo apt -y update
sudo apt -y install tcsh make cmake gcc gfortran flex bison patch bc xorg-dev libbz2-dev wget

以下、cmakeインストール時に確認することです。

  • インストール先は-DCMAKE_INSTALL_PREFIX=<path>で設定する。
  • GCCはUbuntu 22.04のデフォルトであるversion 11.4.0を使用し、-DCOMPILER=GNUでGNU Compilerによるコンパイルを指定する。
  • OpenMPIを利用する場合は、この記事などを参考にしてaptまたはソースコードからのインストールを行っておき、PATHが通った状態で-DMPI=TRUEを設定する。
  • CUDAを使ったMDシミュレーションは最大10倍近く高速なので、aptなどであらかじめ入れておき、-DBUILD_CUDA=TRUEとする。CUDAのバージョンは12.4(AMBER24の場合)までは対応している。
  • QUICKというQM/MMのバッケージを利用するために、-DBUILD_QUICK=TRUEとする。
  • マルチGPU環境でのNCCLを利用した計算を有効化する場合は、環境変数NCCL_HOMEをncclのインストール場所に設定し、-DNCCL=TRUEにする(下の例ではFALSEにしてある)。
tar jxvf AmberTools24.tar.bz2 ; tar jxvf Amber24.tar.bz2
cd amber24_src
# updateを実行する
./update_amber --update
# cmake用のbuildディレクトリに入る
cd build
# ここからcmake処理
AMBER_PREFIX=$(dirname $(dirname `pwd`))
# もしNCCLを有効化したいときは環境変数NCCL_HOMEを設定し、-DNCCL=TRUEにする。
# export NCCL_HOME="/path/to/apps/nccl/2.7.3"
cmake $AMBER_PREFIX/amber24_src \
    -DCMAKE_INSTALL_PREFIX=${HOME}/apps/amber24 \
    -DCOMPILER=GNU -DMPI=TRUE -DOPENMP=TRUE -DBUILD_GUI=FALSE -DCUDA=TRUE \
    -DBUILD_QUICK=TRUE -DINSTALL_TESTS=TRUE -DNCCL=FALSE \
    -DDOWNLOAD_MINICONDA=TRUE 2>&1 | tee cmake.log

# Configureが正常終了していることを確認したらmakeとインストールを実行する
make -j8 install
7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3