a step-by-step guide to installing Psi4 and Forte
This tutorial provides a step-by-step guide for installing the quantum chemistry packages Psi4 and Forte in Windows 11 WSL2.
This guide heavily references from Francesco’s psi4/ambit/forte setup (Mac BigSur 11.6.1, Dec. 2021)
In Windows PowerShell or CMD:
wsl
Enter root mode:
sudo -i
If network access is slow, consider switching to a faster mirror.
Backup:
cp /etc/apt/sources.list /etc/apt/sources.list.backup
Replace the content of /etc/apt/sources.list with a mirror matching your Ubuntu version.
apt update
apt upgrade
apt autoremove
Install development tools:
apt install build-essential gfortran
Install spf13-vim (optional):
curl https://j.mp/spf13-vim3 -L > spf13-vim.sh && sh spf13-vim.sh
Requires NVIDIA driver installed in Windows.
Follow instructions from NVIDIA website.
Example (WSL-Ubuntu, deb network):
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-6
Verify installation:
nvidia-smi
Install Intel Base Toolkit and HPC Toolkit via APT:
sudo apt update
sudo apt install -y gpg-agent wget
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg –dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
echo “deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main” | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt update
sudo apt install intel-basekit
sudo apt install intel-hpckit
Set up the environment:
source /opt/intel/oneapi/setvars.sh
Optionally, add the following to ~/.bashrc so that the variables are automatically loaded every time starting WSL:
. /opt/intel/oneapi/setvars.sh
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
Edit ~/.condarc:
channels:
- conda-forge
- defaults
name: forte
dependencies:
- python=3.12
- pip
- cmake
- clang-format
- numpy
- scipy
- boost
- hdf5
- yaml
- jupyter
- eigen
- pytest
- pydantic
- pint
- pybind11
- pyyaml
- pythreejs
- libint
Create environment:
conda env create -f forte.yml
conda activate forte
Add activation command conda activate forte to ~/.bashrc if desired.
The easiest way to install forte is from conda:
conda install conda-forge::forte
Developers may need to compile Forte manually (see below).
git clone https://github.com/jturney/ambit.git
cd ambit
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/src/ambit-install \
-DCMAKE_C_COMPILER=icx \
-DCMAKE_CXX_COMPILER=icpx
make -j20
make install
Add to ~/.bashrc:
export PYTHONPATH=$HOME/src/ambit-install/lib:$PYTHONPATH
export AMBITPATH=$HOME/src/ambit-install
git clone https://github.com/block-hczhai/block2-preview.git
cd block2-preview
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/src/block2-install \
-DUSE_MKL=ON \
-DBUILD_CLIB=ON \
-DLARGE_BOND=ON \
-DMPI=OFF \
-DCMAKE_C_COMPILER=icx \
-DCMAKE_CXX_COMPILER=icpx
make -j20
make install
Install dependencies:
conda install libxc libecpint dkh gau2grid qcelemental qcengine optking
Clone source:
git clone https://github.com/psi4/psi4.git
cd psi4
mkdir build
cd build
Configure:
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/src/psi4-install \
-DENABLE_dkh=ON \
-DENABLE_ambit=ON \
-DENABLE_ecpint=ON \
-DMAX_AM_ERI=8 \
-Dpsi4_CXX_STANDARD=20 \
-DCMAKE_CXX_STANDARD=20 \
-Dambit_DIR=$HOME/src/ambit-install/share/cmake/ambit \
-DCMAKE_C_COMPILER=icx \
-DCMAKE_CXX_COMPILER=icpx \
-DCMAKE_Fortran_COMPILER=gfortran
Compile:
make -j20
make install
If Eigen error fatal error: ‘eigen3/Eigen/Core’ file not found occurs, you may install a new eigen via sudo apt install libeigen3-dev. Then, remove CMakeCache.txt and CMakeFiles and reconfigure with -DEigen3_DIR=/usr/share/eigen3/cmake.
Add environment variables to ~/.bashrc:
export PSI4OBJ=$HOME/src/psi4/build
export PSI4INS=$HOME/src/psi4-install
export PSIDATADIR=$PSI4INS/share/psi4
export PSI_SCRATCH=/tmp/scratch/psi4
export PYTHONPATH=$PSI4OBJ/stage/lib:$PYTHONPATH
export PATH=$PSI4OBJ/stage/bin:$PATH
Test:
cd $HOME/src/psi4/tests/scf1
psi4
git clone https://github.com/evangelistalab/forte.git
cd forte
9.2.1 Compile via setup.py (Recommended)
Create setup.cfg:
[CMakeBuild]
ambitpath=$HOME/src/ambit-install
cmake_config_options=-DCMAKE_BUILD_TYPE=Debug -DENABLE_block2=ON -DCMAKE_PREFIX_PATH=$HOME/src/block2-install/share/cmake/block2
You need to replace $HOME to full path in the above lines.
Then execute:
python setup.py develop
9.2.2 Manual CMake build using psi4 --plugin-compile
Create compile-forte.sh:
#! /bin/bash
# Modify the following parameters
ambit_dir=$HOME/src/ambit-install/share/cmake/ambit
block2_dir=$HOME/src/block2-install/share/cmake/block2
srcdir=$HOME/src/forte
build_type=Debug
# Run cmake
cd $srcdir
rm -rf CMakeFiles CMakeCache.txt cmake_install.cmake
cmake_psi4=`psi4 –plugin-compile`
$cmake_psi4 -Dambit_DIR=$ambit_dir -DCMAKE_BUILD_TYPE=$build_type -DMAX_DET_ORB=128 -DENABLE_block2=ON -Dblock2_DIR=$block2_dir
# Compile
make -j20
Execute:
bash compile-forte.sh
Set environment variables in ~/.bashrc:
PYTHONPATH=$HOME/src/forte:$PYTHONPATH
cd $HOME/src/forte/tests/method
python run_forte_tests.py --type short
🎉 Hooray! You compiled Forte successfully!
Here are some more articles you might like to read next: