Energy / time profiling on Loihi

Hello,
I’d be interested in profiling time and energy spent in spiking phase on Loihi. I’ve run into similar issues as this post.
When using nxSDK I would create probes like so:

board = nx.N2Compiler().compile(net)
profile_probe_cond = PerformanceProbeCondition(tStart=1, tEnd=run_time, bufferSize=1000, binSize=100)
time_probe = board.probe(nx.ProbeParameter.EXECUTION_TIME, profile_probe_cond)
energy_probe = board.probe(nx.ProbeParameter.ENERGY, profile_probe_cond)
board.run(run_time)
board.disconnect()

However this does not work when using Nengo:

nengo_loihi.hardware.interface.HostSnip.recv_timeout = 1.0  # Default is 0.01 (10 ms)
nengo_loihi.hardware.interface.HostSnip.recv_retries = 100  # Default is 10

with nengo_loihi.Simulator(model, dt = 0.001) as sim:
    profile_probe_cond = PerformanceProbeCondition(tStart=1, tEnd=10000, bufferSize=1024, binSize=100)
    energy_probe = sim.sims["loihi"].nxsdk_board.probe(nx.ProbeParameter.ENERGY, profile_probe_cond)
    sim.run(10)

It ends up in a stacktrace.
You mentioned in the post above that you were running energy profiling succesfully. Could you post your code for comparison please?

1 Like

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

that worked! thanks so much for the quick help

Hi @drasmuss @biphasic,

I just tried to run the code example, and I am running into an issue where I get

INFO:HST:  srun: error: Unable to allocate resources: Requested node configuration is not available

If I remove the probe, the network runs fine. Do you have any ideas what the issue could be? I use nengo 3.1.0 with nengo-loihi from git master.

I remember seeing this error when I tried to profile on a wrong board, like a Nahuku8. Profiling used to work only on Nahuku32 boards, so maybe you find a way to specify the right board (I think it’s called partition if I remember correctly).

Thanks, that would have been the issue indeed! Having trouble connecting to the Nahuku32 boards, but I’ll check that with the Intel team.