[noob alert] running speed of large-scale model

Hello to everyone, i am new to nengo and i just started implementing a paper found on the internet about hierarchical reinforncement learning [https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0180234]. To start with, when i created the model and tried to run it, it was really slow. I cant understand if there is a bottleneck in the code and how can i get a speed equal to 1x (in the down left section). If do you think that there is a performance issue, do you have any suggestions about how can i improve it?

Thanks in advance and sorry for my bad english!

Hi @sizeras, and welcome to the Nengo forums! :smiley:

In the NengoGUI, the speed indicator in the bottom left gives you an approximation of how fast your model is running compared to real time. As an example, if it reads “1”, that means (using the default simulation dt of 1ms), one simulation timestep takes 1ms to complete. If, one simulation timestep took 2ms to complete, the speed indicator would read “0.5”.

The simulation speed of a Nengo model is dependent on a few factors:

  • The size of your Nengo model. This is roughly proportional to the number of neurons in your model.
  • The hardware you are using.
  • Whether or not your are running NengoGUI.

Model Size
Regarding model size, naturally, the larger your model, the slower the simulation will run. This is because your computer needs to run the neuron computation for each neuron in your model. As a quick example, I’ve personally built models with several million neurons, and that took about 3-4 days to run about 30s of simulation time (i.e., the speed indicator would have been ~0.000086)

Computer Hardware
The computer hardware you are running your Nengo model on will also affect your simulation speed. If, for example, you are running it on a laptop processor, it will likely run slower than a desktop or server class processor. Similarly, you can use a package such as NengoOCL to run your simulation on your GPU (if you do have a supported GPU) and this will run your model significantly faster. Using the million+ model example from above, using GPU acceleration decreased the runtime from several days to about 30mins (but the speed indicator would still only be about ~0.017).

Using NengoGUI
If your model is especially complex (i.e., it contains a lot of connections), and you have a lot of them displayed in NengoGUI, it has been known to reduce the speed of your simulation. This is because NengoGUI uses some of your computer resources to render the graphical elements (the lines and boxes and circles) that represent your Nengo model. To get around this, you can run your Nengo model outside of the NengoGUI environment.

You can run Nengo models outside of the NengoGUI environment using the nengo.Simulator object. The Nengo example here illustrates how you would do it. Note that if you want to run your Nengo model outside of the GUI environment, you’ll need to write your own code to display graphs and such (see here for examples).

thank you very much for your response.
While im trying to install nengoOCL, i get this error:
ERROR: Failed building wheel for pyopencl
Running setup.py clean for pyopencl
Failed to build pyopencl

any thoughts?

Which operating system are you using to install NengoOCL?

windows 10, amd gpu

To install pyopencl on a Windows system:

  1. Find out what Python version you are using.
  2. Go to this site: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopencl and download the whl file for your python version. E.g., I tested this install method using a Python 3.7.9 (64bit) environment, so I downloaded the file pyopencl‑2020.3.1+cl12‑cp37‑cp37m‑win_amd64.whl (PyOpenCL version 2020.3.1, OpenCL version 1.2, Python version 3.7, 64bit). Note that there are two OpenCL versions, 1.2 and 2.1 (i.e., cl12 and cl21). Start by trying to install the cl12 version first, and if that fails, uninstall pyopencl and then install the cl21 version.
  3. Install the whl file using: pip install <wheel_file_name>, e.g., pip install pyopencl‑2020.3.1+cl12‑cp37‑cp37m‑win_amd64.whl
  4. Test the installation by starting python, then doing:
import pyopencl as cl
print(cl.get_platforms())
  1. You should see something like: [<pyopencl.Platform 'AMD' at 0x11234567890>]
  2. If you need to, to uninstall pyopencl from your Python environment, do pip uninstall pyopencl

As a side note, it looks like OpenCL support for the latest AMD GPUs might be lacking. What AMD GPU do you have?

AMD Radeon RX vega 10 Graphics

It looks like the AMD Radeon RX Vega 10 does support OpenCL 2.0+, so both versions of the PyOpenCL package might work for you.

1 Like