Thank you for your question.
Using M3GNet requires the installation of pytorch into QuantumATK first. There are two possibilities how to do that in QuantumATK.
Option 1: Installing pytorch in a python virtual environment (venv, see also
https://docs.python.org/3/library/venv.html ):
This is the safe way as it keeps pytorch separated from the QuantumATK installation.
Create a folder with enough space for the venv (we call it $MY_ENV_DIR).
Set up the venv using the python executable in the QuantumATK package:
"$QATK_DIR/atkpython/bin/python" -m venv --system-site-packages "$MY_ENV_DIR"
Activate the venv:
source "$MY_ENV_DIR/bin/activate"
Installing pytorch 2.1
python -m pip install torch==2.1.1 --index-url https://download.pytorch.org/whl/cu118
All simulations need to be run in the activated venv.
The differences to running a simulation via atkpython is:
1. Use the python executable instead of atkpython.
2. Add the line
at the top of the python script you want to run.
Then M3GNet can be imported and set up like a normal calculator in QuantumATK:
from tremolox.neighborlistcalculator.M3GNetCalculator import TremoloXM3GNetDirectPESCalculator
calculator = TremoloXM3GNetDirectPESCalculator(device='cpu')
Option 2: Installing pytorch directly into the QuantumATK installation.
Although we have not encountered any compatibility issue between pytorch and the external modules in quantumatk, there is still a small risk that this can cause problems. Therefore we recommend making a separate installation of QuantumATK for this. The advantage is that the usage is more straightforward.
Install pytorch using pip:
"$QATK_DIR/atkpython/bin/python -m pip install torch==2.1.1 --index-url https://download.pytorch.org/whl/cu118
In this case scripts can directly be run via atkpython, as one is used to.
M3GNet can be imported and set up like a normal calculator in QuantumATK:
from tremolox.neighborlistcalculator.M3GNetCalculator import TremoloXM3GNetDirectPESCalculator
calculator = TremoloXM3GNetDirectPESCalculator(device='cpu')
To use GPU acceleration one can set
Note, these instructions are for Linux systems.
For Windows the steps are identical but some of the directories have to be adapted slightly, e.g. replacing bin/ with Scripts/
In case you encounter problems with disc space during installation of pytorch, we recommend to set the environment variables XDG_CACHE_HOME (for the pip cache) and TMPDIR to directories where enough disc space is available.
Hope this helps.