This example demonstrates how to use the Skala machine learning functional in C++ CPU applications using LibTorch.
Set up the conda environment using the provided environment file:
cd examples/cpp/cpp_integration
conda env create -n skala_cpp_integration -f environment-cpu.yml
conda activate skala_cpp_integrationThe example can be built using CMake. The provided environment is configured for CMake to find the required dependencies.
cmake -S . -B _build -G Ninja
cmake --build _buildFor any changes to the code, rebuild using the last command.
Download the Skala model, as well as a reference LDA functional from HuggingFace using the provided download script:
./download_model.pyPrepare the molecular features for a test molecule (H2) using the provided script:
python ./prepare_inputs.py --output-dir H2Finally, run
./_build/skala_cpp_integration skala-1.0.fun H2Note: You are expected to add D3 dispersion correction (using b3lyp settings) to the final energy of Skala.
This guide from Intel provides useful tips on how to tune performance of PyTorch models on CPU.