brian-team/brian2cuda

Needs patch to run with Brian 2.4.2

mstimberg opened this issue · 2 comments

I just realized that a small change in the brian2.diff is actually necessary to run simulations with Brian 2.4.2, i.e. not only to run the profiling/benchmarks.

Running without the patch fails with

Traceback (most recent call last):
  File "/home/marcel/programming/brian2cuda/examples/stdp.py", line 169, in <module>
    run(100*second, report='text', profile=params['profiling'])
  File "/home/marcel/programming/brian2/brian2/units/fundamentalunits.py", line 2434, in new_f
    result = f(*args, **kwds)
  File "/home/marcel/programming/brian2/brian2/core/magic.py", line 373, in run
    return magic_network.run(duration, report=report, report_period=report_period,
  File "/home/marcel/programming/brian2/brian2/core/magic.py", line 231, in run
    Network.run(self, duration, report=report, report_period=report_period,
  File "/home/marcel/programming/brian2/brian2/core/base.py", line 276, in device_override_decorated_function
    return getattr(curdev, name)(*args, **kwds)
  File "/home/marcel/programming/brian2cuda/brian2cuda/device.py", line 1560, in network_run
    run_lines.extend(self.code_lines['before_run'])
KeyError: 'before_run'

A quick fix that should work with patched and unpatched Brian is to add

        self.code_lines.update({'before_run': [],
                                'after_run': []})

here:

### Reset variables we don't need from CPPStandaloneDevice.__init__()

I didn't try to get Brian2CUDA in it's current version to work with Brian2 2.4.2 without the patch. I wanted to update to Brian2 2.5 now and try to get rid of the patch file altogether in the process.

But if this is the only thing that stops Brian2CUDA to work with Brian2 2.4.2, then I'll happily add that, thanks :)

I think it would make sense to have the current version work with Brian 2.4.2, since we kind of claim that it already does and the patch is only necessary to run benchmarks 😊
But yes, for me this change seems to be all that is needed.