Notebook

Fair-Chem Environment Installation Guide - Based on Conda Env

2024-10-28

fairchem is the FAIR Chemistry's centralized repository of all its data, models, demos, and application efforts for materials science and quantum chemistry.

https://github.com/FAIR-Chem/fairchem


Background

In the official tutorial of Fair-chem, while installing certain dependencies like torch-scatter, torch-sparse, torch-spline-conv, torch-cluster, and torch-geometric, you might encounter some errors. However, there is a feasible way to set up the Fair-chem environment.


Environment Installation Process (Using Conda)

  1. Create a new Conda environment:
    conda create -n fair-chem python=3.10

  2. Enter the fair-chem conda environment:
    conda init
    source ~/.bashrc
    conda activate fair-chem

  3. Install PyTorch with CUDA support in conda env:
    pip install https://download.pytorch.org/whl/cu121/torch-2.4.0%2Bcu121-cp310-cp310-linux_x86_64.whl

    Other versions are theoretically possible as well., Refer to the link at the end of this article.

  4. Install the required dependencies:
    pip install torch-scatter torch-sparse torch-spline-conv torch-cluster torch-geometric -f https://pytorch-geometric.com/whl/torch-2.4.0%2Bcu121.html

  5. Install additional Python libraries(don't need):
    pip install numpy scipy ase matplotlib pandas


Installing Fair-chem

  1. Clone the Fair-chem repository:
    git clone https://github.com/FAIR-Chem/fairchem.git

  2. Navigate to the Fair-chem directory:
    cd fairchem

  3. Install the core package:
    pip install -e packages/fairchem-core[dev]

  4. Install the data processing package:
    pip install -e packages/fairchem-data-oc

  5. Install the application package (optional):
    pip install -e packages/fairchem-applications-cattsunami


    If need other fair-chem packages, we can check them under the /packages floor, and there are also usage demos available.

  6. check Installation:

    >>python,Check installation status:

    import torch

    import torch_geometric

    import torch_scatter

    import torch_sparse

    import torch_cluster

    import torch_spline_conv

    import fairchem

    print("=== Version Info ===")

    print(f"PyTorch: {torch.__version__}")

    print(f"CUDA: {torch.version.cuda}")

    print(f"PyG: {torch_geometric.__version__}")

    print(f"torch_scatter: {torch_scatter.__version__}")

    print(f"torch_sparse: {torch_sparse.__version__}")

    print(f"torch_cluster: {torch_cluster.__version__}")

    print(f"torch_spline_conv: {torch_spline_conv.__version__}")

    print(f"FAIR-Chem: {fairchem.__version__}")


    >>python,List available models:

    from fairchem.core.models.model_registry import available_pretrained_models
    print(available_pretrained_models)

Reference