Nengo slower in Ubuntu 18

Dear Nengo team,

While updating a software from Ubuntu 16 to Ubuntu 18, I have noticed that Nengo runs significantly slower on Ubuntu 18 (up to twice as slow). To be precise, I computed the average time taken by a call to the function run.step() on a simple model (1 ensemble with 1000 neurons), and I obtained an average time of 0.14 ms in Ubuntu 16 and 0.24 in Ubuntu 18.

Is this something that you are aware of? Can I do something to improve Nengo speed on my Ubuntu 18?

Thanks

Alexis

###################################
script used for benchmarking

import nengo
import time

circuit = nengo.Network()
with circuit:
    inpt = nengo.Node([.5]*3)
    sensors = nengo.Ensemble(n_neurons=1000, dimensions=3)
    actors = nengo.Ensemble(n_neurons=2, dimensions=2, neuron_type=nengo.Direct())

    def control(x):
        rl, rr, gb = x
        forward = min(1.0, max(-0.01, (min(rl, rr)) * 100000))
        turn = max(min((rl - rr) * 100, 1), -1)
        if max(rl, rr) < 0.1:
            forward = -0.001
            turn = 0.5
        return forward, turn

    nengo.Connection(inpt, sensors)
    nengo.Connection(sensors, actors, function=control, synapse=0.1)

avg = 0
with nengo.Simulator(circuit) as sim:
    for i in range(1000):
        start = time.time()
        sim.step()
        end = time.time()
        avg += end - start

print("avg time for a sim.step() call (in ms):", avg)

Welcome to the forum @alexis-r! Thanks for the details (script and run-times).

This could have something to do with the linear algebra routines that were compiled with your numpy installation (a library used heavily by the CPU backend for Nengo). If you still have the ability to benchmark on your old environment, you could compare the times reported by a numpy benchmarking script such as: https://gist.github.com/markus-beuckelmann/8bc25531b11158431a5b09a45abd6276

Otherwise I would suggest using conda to create an environment, activate that environment, do conda install numpy, and then pip install nengo. This uses an MKL binary optimized for your particular architecture, which I’ve found in some cases to be twice as fast. Let us know if you need more detailed instructions.

If this does not help, do you have any way of checking that the two versions of nengo are identical (and, if not, which versions)?

Hi Arvoelke

Thanks for your quick answer! I ran the same experiment in conda env and it appeared that the numpy installed with conda and python 2.7 is as fast on Ubuntu 16 and 18!
The conda install is then the key here!
Thanks for the advice,

Alexis

1 Like