3. SustainML Stand-alone library installation¶
The instructions for installing the SustainML Library from sources are provided in this page. It is organized as follows:
The SustainML Library is composed of different software modules, each one related to specific task, which are specialized in solving the different parts of the framework. Each of the modules conforms a Node, which shall import its corresponding Python library, so that each node can be abstracted from the communication between other nodes.
The communication is performed through DDS (Data Distribution Service) protocol, using the eProsima Fast DDS library. During the installation process, some of the Fast DDS requirements will need to be addressed.
The following sections describe the steps to install the SustainML Library on Ubuntu and MacOS.
3.1. SustainML Library dependencies¶
The following packages provide the tools required to install SustainML and its dependencies from command line. General and build tools such as wget, git, CMake, g++, Python3 and SWIG are required. Fast DDS dependencies such as OpenSSL, Asio, TinyXML2, LibP11, and SoftHSM2 are also needed.
Install them using the package manager of the appropriate OS distribution.
On Ubuntu use the following command to install all the dependencies:
apt install --yes --no-install-recommends \
wget git cmake g++ build-essential python3 python3-pip python3.10-venv libpython3-dev swig \
libssl-dev libasio-dev libtinyxml2-dev libp11-dev libengine-pkcs11-openssl softhsm2 && \
sudo apt-get update && \
sudo apt-get install -y openjdk-21-jdk && \
# Add Java 21 to the path (bashrc or .zshrc)
echo 'export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64' >> ~/.bashrc && \
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> ~/.bashrc && \
source ~/.bashrc && \
sudo apt update && sudo apt install -y gnupg ca-certificates wget && \
wget -O - https://debian.neo4j.com/neotechnology.gpg.key | gpg --dearmor | sudo tee /usr/share/keyrings/neo4j.gpg > /dev/null && \
echo "deb [signed-by=/usr/share/keyrings/neo4j.gpg] https://debian.neo4j.com stable latest" | sudo tee /etc/apt/sources.list.d/neo4j.list && \
sudo apt update && \
sudo apt install -y neo4j
On MacOS use the following command to install all the dependencies:
brew install \
wget git llvm cmake gcc python swig openssl@3.0 asio tinyxml2 libp11 softhsm openjdk@21 neo4j
# Add Java 21 to the PATH (bashrc, zshrc or fish config depending on your shell)
echo 'export JAVA_HOME=$(/usr/libexec/java_home -v 21)' >> ~/.zshrc
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> ~/.zshrc
source ~/.zshrc
3.2. Build SustainML Library sources¶
Create a SustainML directory and download the repositories file that will be used to install SustainML Library, and all its repository dependencies (such as the Fast DDS or Fast CDR). The following command builds and installs the SustainML library and its dependencies.
mkdir -p ~/SustainML/SustainML_ws/src && cd ~/SustainML && \
python3 -m venv SustainML_venv && source SustainML_venv/bin/activate && cd ~/SustainML/SustainML_ws && \
pip3 install -U colcon-common-extensions vcstool gdown && \
wget https://raw.githubusercontent.com/eProsima/SustainML-Library/main/sustainml.repos && \
vcs import src < sustainml.repos && \
git submodule update --init --recursive && \
cd ~/SustainML/SustainML_ws/src/sustainml_lib/sustainml_modules/sustainml_modules/sustainml-wp1 && \
gdown --id 1TQvt1bSXares-I9l7Wki0Jge3oubRkOJ -O rag/models_index.ann && \
pip3 install -r ~/SustainML/SustainML_ws/src/sustainml_docs/requirements.txt && \
colcon build && \
sudo neo4j-admin database load system \
--from-path=~/SustainML/SustainML_ws/src/sustainml_lib/sustainml_modules/sustainml_modules/sustainml-wp1/rag/neo4j_backup \
--overwrite-destination=true && \
sudo neo4j-admin database load neo4j \
--from-path=~/SustainML/SustainML_ws/src/sustainml_lib/sustainml_modules/sustainml_modules/sustainml-wp1/rag/neo4j_backup \
--overwrite-destination=true && \
sudo chown -R neo4j:neo4j /var/lib/neo4j/data
mkdir -p ~/SustainML/SustainML_ws/src && cd ~/SustainML && \
python3 -m venv SustainML_venv && source SustainML_venv/bin/activate && cd ~/SustainML/SustainML_ws && \
pip3 install -U colcon-common-extensions vcstool gdown && \
wget https://raw.githubusercontent.com/eProsima/SustainML-Library/macos-compilation/sustainml.repos && \
vcs import src < sustainml.repos && \
git submodule update --init --recursive && \
cd ~/SustainML/SustainML_ws/src/sustainml_lib/sustainml_modules/sustainml_modules/sustainml-wp1 && \
gdown --id 1TQvt1bSXares-I9l7Wki0Jge3oubRkOJ -O rag/models_index.ann && \
pip3 install -r ~/SustainML/SustainML_ws/src/sustainml_docs/requirements.txt && \
colcon build --cmake-args -DCMAKE_CXX_STANDARD=17 && \
sudo neo4j-admin database load system \
--from-path=~/SustainML/SustainML_ws/src/sustainml_lib/sustainml_modules/sustainml_modules/sustainml-wp1/rag/neo4j_backup \
--overwrite-destination=true && \
sudo neo4j-admin database load neo4j \
--from-path=~/SustainML/SustainML_ws/src/sustainml_lib/sustainml_modules/sustainml_modules/sustainml-wp1/rag/neo4j_backup \
--overwrite-destination=true && \
sudo chown -R neo4j:neo4j /var/lib/neo4j/data
3.3. Run SustainML Modules and Backend¶
After building the SustainML library, you can start the backend as follows:
bash -c " \
systemctl start neo4j && \
cd ~/SustainML/SustainML_ws/build/sustainml_modules/lib/sustainml_modules; \
python3 sustainml-wp1/app_requirements_node.py & \
python3 sustainml-wp1/ml_model_metadata_node.py & \
python3 sustainml-wp1/ml_model_provider_node.py & \
python3 sustainml-wp2/hw_constraints_node.py & \
python3 sustainml-wp2/hw_resources_provider_node.py & \
python3 sustainml-wp3/carbon_footprint_node.py & \
python3 sustainml-wp5/backend_node.py”
bash -c " \
brew services start neo4j && \
cd ~/SustainML/SustainML_ws/build/sustainml_modules/lib/sustainml_modules; \
python3 sustainml-wp1/app_requirements_node.py & \
python3 sustainml-wp1/ml_model_metadata_node.py & \
python3 sustainml-wp1/ml_model_provider_node.py & \
python3 sustainml-wp2/hw_constraints_node.py & \
python3 sustainml-wp2/hw_resources_provider_node.py & \
python3 sustainml-wp3/carbon_footprint_node.py & \
python3 sustainml-wp5/backend_node.py”