Installation¶
CodeGreen can be installed via the automated script or built manually from source.
Quick Install (Recommended)¶
What this does:
- Checks system requirements (Python 3.8+, CMake, g++)
- Initializes git submodules (Tree-sitter grammars)
- Installs Python dependencies
- Builds the NEMB C++ backend (
libcodegreen-nemb.so) - Installs the
codegreenCLI via pip - Sets up RAPL sensor permissions (creates
codegreengroup, udev rule)
Running with sudo handles RAPL permissions automatically. After install, log out and back in for group changes to take effect. No sudo needed after that.
If installed without sudo, set up sensors separately:
Manual Build¶
Prerequisites¶
- Python: 3.8+
- CMake: 3.16+
- C++ Compiler: GCC 7+ or Clang (C++17 support)
- Libraries:
libjsoncpp-dev,libcurl4-openssl-dev,libsqlite3-dev
Build Steps¶
-
Clone and Initialize:
-
Build C++ Core:
-
Install Python Package:
Optional: Visualization Support¶
For --export-plot HTML export:
For PNG/PDF static export:
Or install all visualization dependencies:
Development Installation¶
For contributors:
git clone https://github.com/SMART-Dal/codegreen.git
cd codegreen
pip install -e ".[dev]"
pre-commit install
Hardware Requirements¶
CodeGreen's NEMB (Native Energy Measurement Backend) supports the following hardware sensors on Linux:
| Sensor | Requirements | Description |
|---|---|---|
| Intel RAPL | Intel/AMD CPU | CPU package, core, DRAM energy via /sys/class/powercap |
| NVIDIA NVML | NVIDIA GPU + drivers 450.80+ | GPU power via NVML library |
| AMD ROCm | AMD GPU + ROCm | GPU power via ROCm SMI |
| AMD RAPL | AMD CPU | CPU energy via RAPL interface |
Note: CodeGreen supports Linux, macOS, and Windows. Hardware sensor availability varies by platform.
Troubleshooting¶
Command not found:
Ensure your installation directory is in your PATH:
Permission denied (RAPL):
This creates a codegreen group with read-only access to /sys/class/powercap/ energy counters and a udev rule for persistence across reboots. Verify with groups | grep codegreen after relogin.
Missing dependencies:
Getting Help¶
- Check the CLI Reference
- Run
codegreen doctor --verbose - Open an issue on GitHub