Install Graphsignal agent by running:
pip install graphsignal
Or clone and install the GitHub repository:
git clone https://github.com/graphsignal/graphsignal.git python setup.py install
Configure Graphsignal agent by specifying your API key directly or via
GRAPHSIGNAL_API_KEY environment variable.
import graphsignal graphsignal.configure(api_key='my-api-key')
To track deployments, versions and environments separately, specify a
deployment parameter, e.g.
Use the following examples to integrate Graphsignal agent into your machine learning application. See integration documentation and API reference for full reference.
Graphsignal agent is optimized for production. All executions wrapped with
start_trace method will be measured, but only a few will be recorded and profiled to ensure low overhead.
To measure and trace executions, wrap the code with
with graphsignal.start_trace(endpoint='my-model-predict'): # function call or code segment
Other integrations are available as well. See integration documentation for more information.
Enable/disable various code profilers depending on the code and model runtime by passing
profiler argument to
start_trace method. By default
True and Python profiler is enabled. Set to
False to disable profiling.
with graphsignal.start_trace(endpoint='my-model-predict', profiler='pytorch'): # function call or code segment
The following values are currently supported:
onnxruntime. See integration documentation for more information on each profiler.
with context manager is used with
start_trace method, exceptions are automatically recorded. For other cases, use
To track data metrics and record data profiles,
EndpointTrace.set_data method can be used.
with graphsignal.start_trace(endpoint='my-model-predict') as trace: trace.set_data('input', input_data)
The following data types are currently supported:
No raw data is recorded by the agent, only statistics such as size, shape or number of missing values.
After everything is setup, log in to Graphsignal to monitor and analyze execution performance and monitor for issues.
import graphsignal graphsignal.configure(api_key='my-api-key') ... def predict(x): with graphsignal.start_trace(endpoint='my-model-predict'): return model(x)
import graphsignal graphsignal.configure(api_key='my-api-key') .... for x in data: with graphsignal.start_trace(endpoint='my-model-predict', tags=dict(job_id='job1')): preds = model(x)
More integration examples are available in
Although profiling may add some overhead to applications, Graphsignal only profiles certain executions, automatically limiting the overhead.
To enable debug logging, add
configure(). If the debug log doesn't give you any hints on how to fix a problem, please report it to our support team via your account.
In case of connection issues, please make sure outgoing connections to
For GPU profiling, if
libcupti agent is failing to load, make sure the NVIDIA® CUDA® Profiling Tools Interface (CUPTI) is installed by running:
/sbin/ldconfig -p | grep libcupti