FAIR-Chem Core
raw JSON → 2.19.0 verified Sat May 09 auth: no python
fairchem-core is the core package of the FAIR Chemistry library, providing machine learning models (e.g., GemNet-OC, DimeNet++) for chemistry and materials science. Version 2.19.0 supports Python 3.11 to 3.13. The library is actively maintained and released every few months.
pip install fairchem-core Common errors
error ImportError: cannot import name 'OC20Dataset' from 'fairchem.core.data' ↓
cause Incorrect import path; the dataset classes are in `fairchem.core.datasets`.
fix
Change import to
from fairchem.core.datasets import OC20Dataset. error ModuleNotFoundError: No module named 'fairchem' ↓
cause `fairchem-core` is not installed, or is installed in a different Python environment.
fix
Run
pip install fairchem-core and ensure you are using the correct Python interpreter. error RuntimeError: Expected tensor to be on GPU, but found tensor on CPU ↓
cause Model expects a CUDA tensor, but data was loaded on CPU.
fix
Move model and data to GPU:
model = model.cuda(); data = {k: v.cuda() for k, v in batch.items()}. Warnings
breaking The package structure changed from `fairchem` to `fairchem.core` in version 2.0. Code using `from fairchem import ...` will break. ↓
fix Update imports to use `fairchem.core` instead of `fairchem`.
gotcha Requires PyTorch with CUDA. CPU-only will fail if GPU expects CUDA tensors. ↓
fix Install PyTorch with CUDA: `pip install torch --index-url https://download.pytorch.org/whl/cu118`
deprecated The `OC22Dataset` is deprecated in favor of `OC20Dataset` with appropriate parameters. ↓
fix Use `OC20Dataset` with `task='oc22'` if available.
Imports
- OC20Dataset wrong
from fairchem.core.data import OC20Datasetcorrectfrom fairchem.core.datasets import OC20Dataset
Quickstart
import torch
from fairchem.core.models import GemNetOC
from fairchem.core.datasets import OC20Dataset
dataset = OC20Dataset("s2ef", split="train", subset="200k", root="./data")
loader = torch.utils.data.DataLoader(dataset, batch_size=32, shuffle=True)
model = GemNetOC()
output = model(next(iter(loader)))
print(output)