Installation#
Basic install#
Install the latest release from PyPI:
pip install scope-profiler
This pulls in the only hard dependencies: numpy and h5py.
Optional extras#
scope-profiler ships several optional dependency groups that you can install with the bracket syntax:
Extra |
Install command |
What it adds |
|---|---|---|
|
|
LIKWID hardware counters via pylikwid |
|
|
Line-by-line profiling via line_profiler |
|
|
NVTX ranges for NVIDIA Nsight profiling |
|
|
The |
|
|
MPI support via mpi4py |
|
|
Plotting, post-processing, and TUI browsing ( |
|
|
All of the above plus linting, formatting, and docs tools |
The base install pulls in only h5py and numpy. Recording timings,
writing HDF5 and scope-profiler inspect all work with that alone; the
extras are needed only for the features they name.
use_line_profiler=True raises a clear ImportError if the
line-profiler extra is not installed, as use_likwid=True does for
pylikwid.
Development install#
Clone the repository and install in editable mode with all development dependencies:
git clone https://github.com/max-models/scope-profiler.git
cd scope-profiler
pip install -e ".[dev]"
LIKWID (optional)#
LIKWID hardware counter support requires the LIKWID library and the pylikwid Python bindings to be installed on the system. See the LIKWID documentation for build instructions.
pip install "scope-profiler[likwid]" installs the pylikwid bindings,
but they build against an existing LIKWID installation — install (or
module load) LIKWID first.
pylikwid is linked against liblikwid.so, and many cluster modules
put likwid-perfctr on PATH without adding the library to
LD_LIBRARY_PATH, which makes import pylikwid fail with
ImportError: liblikwid.so.5: cannot open shared object file.
scope-profiler recovers from this on its own: it locates the library via
LIKWID_HOME / LIKWID_ROOT (or the prefix of likwid-perfctr on
PATH) and loads it before importing the bindings, so
module load likwid is enough.
If LIKWID lives somewhere none of those point to, set the loader path yourself before starting Python:
export LD_LIBRARY_PATH="/path/to/likwid/lib:$LD_LIBRARY_PATH"
python -c "import pylikwid"
Counters are only recorded when the process is started under LIKWID’s
marker mode — likwid-perfctr -C 0 -g CLOCK -m python script.py, or
likwid-mpirun ... -marker. Run the script plainly and the marker calls
become no-ops: the timings are still recorded, there are simply no
counters. See LIKWID hardware counters.
Verify installation#
>>> from scope_profiler import ProfileManager
>>> ProfileManager.setup()
>>> with ProfileManager.profile_region("test"):
... pass
>>> ProfileManager.finalize()
profiling_data.h5 (1 rank(s))
region ranks calls total [s] avg [s]
...