SPARC Installation Guide

This guide provides step-by-step instructions to install SPARC. Currently SPARC supports DeePMD-kit version 2.2.10 for ML arcitechture, however with the next version we plan to also support DeePMD-kit 3.

After the installation, sparc will be available to execute.

Dependencies:

Core Software Dependencies

Python

>= 3.9

DeepMD-kit

2.2.10

ASE

3.24.0

VASP/CP2K

PLUMED

Python Package Dependencies:

  • numpy

  • pandas

  • dpdata

Note

Assuming Anaconda is already installed in the Linux environment. If not then follow the instructions here.

Step-by-Step Installation

  1. Create and activate a conda environment:

    conda create -n sparc python=3.10
    conda activate sparc
    
  2. Use any of the following methods to install DeepMD-kit :

  • conda

    conda install deepmd-kit=2.2.10=*gpu libdeepmd=2.2.10=*gpu lammps horovod -c https://conda.deepmodeling.com -c defaults
    
  • pip

    pip install deepmd-kit[gpu,cu12]==2.2.10
    

Important

Deepmd-kit pip install tensorflow[and-cuda] may not always detect the GPU due to potential configuration issues. To verify if TensorFlow has successfully recognized the GPU, execute the following command,

(sparc):~$ python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
(sparc):~$ [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU'), PhysicalDevice(name='/physical_device:GPU:1', device_type='GPU')]

If the output is an empty list,

(sparc):~$ Skipping registering GPU devices...
(sparc):~$ []

Check,

  • NVIDIA driver and CUDA toolkit installation

  • CUDA version compatibility with TensorFlow

  • Linux environment variables (e.g., LD_LIBRARY_PATH) are correctly set

Also, refer to the TensorFlow GPU troubleshooting guide for details.

Some hardware have also shown issues with conda channels:

LibMambaUnsatisfiableError: Encountered problems while solving:
nothing provides __cuda needed by libdeepmd-2.2.10-0_cuda10.2_gpu
nothing provides __cuda needed by tensorflow-2.9.0-cuda102py310h7cc18f4_0
Could not solve for environment specs
The following packages are incompatible
├─ deepmd-kit 2.2.10 *gpu is not installable because it requires
│  └─ tensorflow 2.9.* cuda*, which requires
│     └─ __cuda, which is missing on the system;
└─ libdeepmd 2.2.10 *gpu is not installable because it requires
└─ __cuda, which is missing on the system.
  1. Clone and install SPARC:

    git clone https://github.com/rahulumrao/sparc.git
    cd sparc
    pip install .
    
  1. Install PLUMED:

    conda install -c conda-forge py-plumed
    

Note

Some Collective Variables (CVs), such as Generic CVs (e.g., SPRINT), are part of the additional module and are not included in a standard PLUMED installation. To enable them, we need to manually install PLUMED and wrap with Python.

Download the PLUMED package from the official website. During installation, PLUMED will detect the Python interpreter from the active conda environment and enable Python bindings.

./configure --enable-mpi=no --enable-modules=all PYTHON_BIN=$(which python) --prefix=$CONDA_PREFIX

make -j$(nproc) && make install

Once the installation is complete, a directory named plumed inside the lib folder inside conda environment.

To verify the installation, run the following command in the terminal:

>>> ls /home/user/anaconda3/envs/sparc/lib/plumed

Expected output:

fortran     patches        plumed-mklib  plumed-partial_tempering  plumed-runtime   plumed-vim2html  src
modulefile  plumed-config  plumed-newcv  plumed-patch              plumed-selector  scripts          vim

You can also import the module in Python to confirm installation:

>>> from ase.calculators.plumed import Plumed
>>> help(Plumed)
   Help on class Plumed in module ase.calculators.plumed:
   class Plumed(ase.calculators.calculator.Calculator)
   |  Plumed(calc, input, timestep, atoms=None, kT=1.0, log='', restart=False, use_charge=False, update_charge=False)
   |
   |  Method resolution order:
   |      Plumed
   |      ase.calculators.calculator.Calculator
   |      ase.calculators.calculator.BaseCalculator
   |      ase.calculators.abc.GetPropertiesMixin

Verification

Once installed with all dependencies, the command-line execution will prints:

>>> sparc -h

   sparc [-h] [-i INPUT_FILE]

   options:
   -h, --help            show this help message and exit
   -i INPUT_FILE, --input_file INPUT_FILE
                           Input YAML file

Warning

This package is under active development, therefore some features and APIs may change. Also, this workflow is designed to work in a Linux environment. It may not be fully compatible with macOS systems.