Package: nengo-ocl
OpenCL-based Nengo SimulatorNengoOCL is an OpenCL-based simulator for
brain models built usingNengo.
It can be orders of magnitude faster than the reference simulator
innengofor large models.UsageTo use thenengo_oclproject’s OpenCL simulator,
build a Nengo model as usual,
but usenengo_ocl.Simulatorwhen creating a simulator for your model:import numpy as np
import matplotlib.pyplot as plt
import nengo
import nengo_ocl

# define the model
with nengo.Network() as model:
    stim = nengo.Node(np.sin)
    a = nengo.Ensemble(100, 1)
    b = nengo.Ensemble(100, 1)
    nengo.Connection(stim, a)
    nengo.Connection(a, b, function=lambda x: x**2)

    probe_a = nengo.Probe(a, synapse=0.01)
    probe_b = nengo.Probe(b, synapse=0.01)

# build and run the model
with nengo_ocl.Simulator(model) as sim:
    sim.run(10)

# plot the results
plt.plot(sim.trange(), sim.data[probe_a])
plt.plot(sim.trange(), sim.data[probe_b])
plt.show()If you are running withinnengo_guimake sure thePYOPENCL_CTXenvironment variable has been set. If this variable is not set it will open
an interactive prompt which will causenengo_guito get stuck during build.Dependencies and InstallationThe requirements are the same as Nengo, with the additional Python packagesmakoandpyopencl(where the latter requires installing OpenCL).General:Python 2.7+ or Python 3.3+ (same as Nengo)One or more OpenCL implementations (test with e.g. PyOpenCl)A working installation of OpenCL is the most difficult
part of installing NengoOCL. See below for more details
on how to install OpenCL.Python packages:NumPynengomakoPyOpenCLIn the ideal case, all of the Python dependencies
will be automatically installed when installingnengo_oclwithpipinstallnengo-oclIf that doesn’t work, then do a developer install
to figure out what’s going wrong.Developer InstallationFirst,pip install nengo.
For best performance, first make sure a fast version of Numpy is installed
by following the instructions in theNengo README.This repository can then be installed with:gitclonehttps://github.com/nengo/nengo-ocl.gitcdnengo-oclpythonsetup.pydevelop--userIf you’re using avirtualenv(recommended!)
then you can omit the--userflag.
Check the output to make sure everything installed correctly.
Some dependencies (e.g.pyopencl) may require manual installation.Installing OpenCLHow you install OpenCL is dependent on your hardware and operating system.
A good resource for various cases is found in the PyOpenCL documentation:Installing PyOpenCL on WindowsInstalling PyOpenCL on Mac OS XInstalling PyOpenCL on Linux,
and amore detailed guideBelow are instructions that have worked for the
NengoOCL developers at one point in time.AMD OpenCL on Debian UnstableOn Debian unstable (sid) there are packages in non-free and contrib
to install AMD’s OpenCL implementation easily.
Actually, the easiest thing would be to apt-get installpython-pyopencl.
But if you’re using a virtual environment, you cansudoapt-getinstallopencl-headerslibboost-python-devamd-opencl-icdamd-libopencl1and thenpip install pyopencl.Nvidia OpenCL on Debian/Ubuntu LinuxOn Debian unstable (sid) there are packages
for installing the Nvidia OpenCL implementation as well.sudoapt-getinstallnvidia-opencl-commonnvidia-libopencl1Ensure that the Nvidia driver version matches the OpenCL library version.
You can check the Nvidia driver version by runningnvidia-smiin the
command line. You can find the OpenCL library version by looking at the
libnvidia-opencl.so.XXX.XX file in the/usr/lib/x86_64-linux-gnu/folder.Intel OpenCL on Debian/Ubuntu LinuxThe Intel SDK for OpenCL is no longer available. Intel OpenCL drivers
can be foundon Intel’s website.
Seethe PyOpenCL wikifor instructions.Running TestsFrom thenengo-oclsource directory, run:py.testnengo_ocl/tests--pyargsnengo-vThis will run the tests using the default context. If you wish to use another
context, configure it with thePYOPENCL_CTXenvironment variable
(run the Python commandpyopencl.create_some_context()for more info).Release History3.0.0 (November 16, 2023)Compatible with Nengo 3.1.0AddedThe benchmarks in theexamplesfolder now have nicer command-line interfaces.
Use the--helpflag with any benchmark to learn more about the options. (#187)The newexamples/benchmark_backends.pyscript makes it easier to compare between
different backends on any of the benchmarks. (#187)ChangedSparse matrix multiplication is now faster in many cases by using the ELLPACK matrix
format. It uses more memory for some sparse matrices, though; for matrices where it
would result in a large increase in memory usage, we fall back on the old CSR format.
To force a particular format, set theNENGO_OCL_SPMV_ALGORITHMenvironment
variable to either “ELLPACK” or “CSR”. (#188)Made NengoOCL available under the GPLv2 license. (#191)RemovedDropped support for Python 3.5. (#187)2.1.0 (Nov 23, 2020)Compatible with Nengo 3.1.0AddedAddedremove_zero_incsandremove_unmodified_resetssimplifications for
the operator list. These are enabled by default, and remove unnecessary operators
(e.g. that are multiplying by zero and adding that to a signal). This increases both
build speed and run speed. These simplifications can be disabled by modifyingnengo_ocl.operators.simplifications. (#183)ChangedAdded support for Nengo 3.1.0, and retired support for Nengo 3.0.0. (#180)Changes to improve benchmarks, including comparing between benchmarks. (#182)2.0.0 (Sept 4, 2020)Compatible with Nengo 3.0.0AddedSparsetransforms are now supported. (#176)AddedSimulator.clear_probesmethod to clear probe data stored in memory.
(#179)ChangedNow requires Python >= 3.5. (#172)Now supports Nengo 3.0.0. Note that support for previous Nengo
versions has been dropped. (#172)Convolutiontransforms are now supported. The previous code supportingConv2dandPool2dprocesses (from NengoExtras) has been removed. (#172)1.4.0 (July 4, 2018)ImprovementsSupports recent Nengo versions, up to 2.8.0.Supports the newSpikingRectifiedLinearneuron type.1.3.0 (October 6, 2017)ImprovementsSupports recent Nengo versions, up to 2.6.0.BugfixesFixed an issue in which stochastic processes would not be
fully reset on simulator reset.Fixed an issue in which building a model multiple times
could result in old probe data persisting.1.2.0 (February 23, 2017)ImprovementsSupports all Nengo versions from 2.1.2 to 2.3.1.nengo_ocl.Simulatoris no longer a subclass ofnengo.Simulator,
reducing the chances that Nengo OCL will be affected by changes in Nengo.1.1.0 (November 30, 2016)FeaturesAdded support forRectifiedLinearandSigmoidneuron types.Added support for arbitraryProcesssubclasses. Unlike the processes
that are explicitly supported likeWhiteSignal, these processes
may not fully utilize the OpenCL device.Added support for applying synaptic filters to matrices,
which is commonly done when probing connection weights.ImprovementsSupports all Nengo versions from 2.1.2 to 2.3.0.TheLIFmodel is now more accurate, and matches the implementation
in Nengo (seeNengo#975).Several operators have been optimized and should now run faster.BugfixesFixed compatibility issues with Python 3,
and certain versions of NumPy and Nengo.1.0.0 (June 6, 2016)Release in support of Nengo 2.1.0. Since Nengo no longer supports Python 2.6,
we now support Python 2.7+ and 3.3+.FeaturesAdded support forProcessclass and subclasses, new in Nengo in 2.1.0.
We specifically support theWhiteNoise,WhiteSignal, andPresentInputprocesses. We also support theConv2dandPool2dprocesses innengo_extras.LinearFilteris now fully supported, allowing for general synapses.ImprovementsThe Numpy simulator in this project (sim_npy) has been phased out and
combined with the OCL simulator (sim_ocl). It is now calledSimulatorand resides insimulator.py.Operator scheduling (i.e. the planner) is much faster. We still have only
one planner (greedy_planner), which now resides inplanners.py.Many small speed improvements, including a number of cases where data was
needlessly copied off the device to check sizes, dtypes, etc.DocumentationUpdated examples to use up-to-date Nengo syntax.0.1.0 (June 8, 2015)Initial release of Nengo OpenCL!
Supports Nengo 2.0.x on Python 2.6+ and 3.3+.