Energy / time profiling on Loihi

Hello @biphasic,

Here is a code example that should work:

import nengo
import nengo_loihi
from nxsdk.graph.monitor.probes import PerformanceProbeCondition
from nxsdk.api.n2a import ProbeParameter

with nengo.Network() as net:
    a = nengo.Ensemble(10, 1)
    p = nengo.Probe(a)

run_time = 0.1
dt = 0.001

sim = nengo_loihi.Simulator(net, dt=dt)
board = sim.sims["loihi"].nxsdk_board
probe_cond = PerformanceProbeCondition(
    tStart=1, tEnd=int(run_time / dt) * 10, bufferSize=1024 * 5, binSize=4
)
e_probe = board.probe(ProbeParameter.ENERGY, probe_cond)

with sim:
    sim.run(run_time)

Note that the important difference is that we’re adding the energy probe before the with sim block. with sim will run some NxSDK initialization code, and NxSDK gives that error if you try to add energy probes after that initialization code is run.

1 Like