NEML2 2.0.0
|
Compiling the NEML2 core library requires
NEML2 is built upon and relies on a collection of third party libraries/packages, most notably PyTorch (and its C++ backend libtorch). However, there is no need to install dependencies prior to installing NEML2. The build system will automatically search for necessary packages. When a required package is missing, the build system will download one.
Refer to dependency management for a list of dependent libraries/packages and more information on the search procedure.
First, obtain the NEML2 source code.
Then, configure and build NEML2.
The --preset
option specifies a predefined configuration to be read by CMake. Build customization, available presets, and their usage scenario are discussed in build customization.
Optionally, NEML2 can be installed as a system library.
The --prefix
option specifies the path where NEML2 will be installed. Write permission is needed for the installation path. The --component libneml2
option tells CMake to only install the libraries and runtime artifacts. NEML2 has three installable components:
libneml2
: core libraries and public headerslibneml2-bin
: executables and utilities such as the runnerlibneml2-python
: Python bindings, submodules, and scriptsNEML2 also provides an experimental Python package which provides bindings for the primitive tensors and parsers for deserializing and running material models. Package source distributions are available on PyPI, but package wheels are currently not built and uploaded to PyPI.
To install the NEML2 Python package, run the following command at the repository's root.
Two optional environment variables can be used to control the build: CMAKE_GENERATOR
specifies the CMake generator, and CMAKE_BUILD_JOBS
specifies the number of parallel jobs used to build the package.
Once installed, the package can be imported in Python scripts using
For security reasons, static analysis tools and IDEs for Python usually refuse to extract function signature, type hints, etc. from binary extensions such as the NEML2 Python bindings. As a workaround, NEML2 automatically generates "stubs" using pybind11-stubgen
immediately after Python bindings are built to make them less opaque. Refer to the pybind11-stubgen documentation for more information.