Running a model - abr/telluride-nengo GitHub Wiki

Be sure that you activate your environment before running models: source activate loihi. nengo_loihi.Simulator is how you run models in nengo_loihi. It works much the same as the regular nengo.Simulator (you can read more about that in the Nengo documentation if you are new to Nengo), with a few extra arguments.

Here is a basic example of creating a Nengo model and running it on Loihi (note: you should first follow the instructions for installing and connecting to Loihi).

import nengo
import nengo_loihi

model = nengo.Network()
with model:
    stim = nengo.Node(0.5)
    ens = nengo.Ensemble(10, 1)
    nengo.Connection(stim, ens)
    p = nengo.Probe(ens)

with nengo_loihi.Simulator(model) as sim:
    sim.run(1.0)

Simulator arguments

nengo_loihi.Simulator has two extra parameters (beyond those in the standard nengo.Simulator) that you need to know about.

target

nengo_loihi.Simulator can be used to run your model on a physical Loihi board or on a software simulation of the board. This is specified with the target parameter:

with nengo_loihi.Simulator(net, target="loihi") as sim:

There are currently three valid values for target:

  • 'loihi': Runs the model on a physical board (must have NxSDK installed and be connected to a board)
  • 'sim': Runs the model using a simulation of the board
  • 'simreal': Runs the model using a simulation of the board with floating point precision (as opposed to the integer discretization present on the real board)

precompute

You can create your Simulator with

with nengo_loihi.Simulator(net, precompute=True/False) as sim:
  • Use precompute=True if your model does not require live interaction between the Loihi board and the host. This will generally simplify and speed up the simulation of your model.
  • Use precompute=False if your model does require live interaction (e.g., you have a nengo.Node that is receiving input from the simulation and doing some processing, as in online learning). This will generally be slower.

Troubleshooting

Restarting the n2driverservice daemon

The daemon that runs the n2driverservice script can be restarted using the following command on the respective loihi boards:

sudo systemctl restart n2driverservice