Description of problem
My code for some network model is not compiling any longer after Brian’s last upgrade – i.e., from version 2.2.x (or maybe 2.3.x) to v2.4+git. It is hard to figure out what has changed – but everything was working fine before.
I suppose that the way of handling multiple consecutive runs in standalone mode has changed with the last version. This issue at least seems related to this aspect.
Minimal code to reproduce the problem
The following MWE precisely reproduces the problem:
import os
from brian2 import *
code_dir = os.path.abspath('./code_gen') # It is better to provide always the absolute path
set_device('cpp_standalone',directory=code_dir,build_on_run=False)
device.delete(force=True) # Clean codegen directory for safety
defaultclock.dt = 5e-4*second
# Sample code
N_neurons = 10
# Jvals = np.r_[1.0] # Single run: This will just build fine the error
Jvals = np.arange(0.5,2.5,0.2) # Multiple runs: FAILS
G = NeuronGroup(N_neurons, 'dv/dt = -v / (10*ms) : 1',
threshold='v > 1', reset='v = 0', name='neu')
S = Synapses(G, G, model='w:1', on_pre='v+=w', namespace={'J': 0.0},name='syn')
S.connect('i!=j')
prefs.devices.cpp_standalone.openmp_threads = 12
mynet = Network([G,S])
duration = 1.0*second
for j in Jvals:
mynet['syn'].namespace['J'] = j
mynet['syn'].w = 'J*rand()'
mynet.run(duration=duration,report='text')
device.build(directory=code_dir)
What you have already tried.
It is clearly a problem with the handling of multiple runs in standalone with the upgrade. If you use only one run for a single parameter it will just build fine.
Expected output (if relevant)
N/A
Actual output (if relevant)
The full error message:
INFO No numerical integration method specified for group 'neu', using method 'exact' (took 0.03s). [brian2.stateupdaters.base.method_choice]
WARNING OpenMP code is not yet well tested, and may be inaccurate. [brian2.devices.cpp_standalone.device.openmp]
makefile:18: recipe for target 'main' failed
code_objects/before_run_syn_pre_push_spikes.o: In function `_before_run_syn_pre_push_spikes()':
before_run_syn_pre_push_spikes.cpp:(.text+0x0): multiple definition of `_before_run_syn_pre_push_spikes()'
code_objects/before_run_syn_pre_push_spikes.o:before_run_syn_pre_push_spikes.cpp:(.text+0x0): first defined here
code_objects/before_run_syn_pre_push_spikes.o: In function `_before_run_syn_pre_push_spikes()':
before_run_syn_pre_push_spikes.cpp:(.text+0x0): multiple definition of `_before_run_syn_pre_push_spikes()'
code_objects/before_run_syn_pre_push_spikes.o:before_run_syn_pre_push_spikes.cpp:(.text+0x0): first defined here
code_objects/before_run_syn_pre_push_spikes.o: In function `_before_run_syn_pre_push_spikes()':
before_run_syn_pre_push_spikes.cpp:(.text+0x0): multiple definition of `_before_run_syn_pre_push_spikes()'
code_objects/before_run_syn_pre_push_spikes.o:before_run_syn_pre_push_spikes.cpp:(.text+0x0): first defined here
code_objects/before_run_syn_pre_push_spikes.o: In function `_before_run_syn_pre_push_spikes()':
before_run_syn_pre_push_spikes.cpp:(.text+0x0): multiple definition of `_before_run_syn_pre_push_spikes()'
code_objects/before_run_syn_pre_push_spikes.o:before_run_syn_pre_push_spikes.cpp:(.text+0x0): first defined here
code_objects/before_run_syn_pre_push_spikes.o: In function `_before_run_syn_pre_push_spikes()':
before_run_syn_pre_push_spikes.cpp:(.text+0x0): multiple definition of `_before_run_syn_pre_push_spikes()'
code_objects/before_run_syn_pre_push_spikes.o:before_run_syn_pre_push_spikes.cpp:(.text+0x0): first defined here
code_objects/before_run_syn_pre_push_spikes.o: In function `_before_run_syn_pre_push_spikes()':
before_run_syn_pre_push_spikes.cpp:(.text+0x0): multiple definition of `_before_run_syn_pre_push_spikes()'
code_objects/before_run_syn_pre_push_spikes.o:before_run_syn_pre_push_spikes.cpp:(.text+0x0): first defined here
code_objects/before_run_syn_pre_push_spikes.o: In function `_before_run_syn_pre_push_spikes()':
before_run_syn_pre_push_spikes.cpp:(.text+0x0): multiple definition of `_before_run_syn_pre_push_spikes()'
code_objects/before_run_syn_pre_push_spikes.o:before_run_syn_pre_push_spikes.cpp:(.text+0x0): first defined here
code_objects/before_run_syn_pre_push_spikes.o: In function `_before_run_syn_pre_push_spikes()':
before_run_syn_pre_push_spikes.cpp:(.text+0x0): multiple definition of `_before_run_syn_pre_push_spikes()'
code_objects/before_run_syn_pre_push_spikes.o:before_run_syn_pre_push_spikes.cpp:(.text+0x0): first defined here
code_objects/before_run_syn_pre_push_spikes.o: In function `_before_run_syn_pre_push_spikes()':
before_run_syn_pre_push_spikes.cpp:(.text+0x0): multiple definition of `_before_run_syn_pre_push_spikes()'
code_objects/before_run_syn_pre_push_spikes.o:before_run_syn_pre_push_spikes.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
make: *** [main] Error 1
ERROR Brian 2 encountered an unexpected error. If you think this is a bug in Brian 2, please report this issue either to the mailing list at <http://groups.google.com/group/brian-development/>, or to the issue tracker at <https://github.com/brian-team/brian2/issues>. Please include this file with debug information in your report: /tmp/brian_debug_t7ggz793.log Additionally, you can also include a copy of the script that was run, available at: /tmp/brian_script_1q3edmac.py You can also include a copy of the redirected std stream outputs, available at /tmp/brian_stdout_k4g2zt4y.log and /tmp/brian_stderr_n4t3ql69.log Thanks! [brian2]
Traceback (most recent call last):
File "/home/mdepitta/Ongoing.Projects/DePitta.PNAS/Software/NGN.Spiking.Network/testing_brian_modules.py", line 28, in <module>
device.build(directory=code_dir)
File "/home/mdepitta/local/brian2/brian2/devices/cpp_standalone/device.py", line 1253, in build
self.compile_source(directory, compiler, debug, clean)
File "/home/mdepitta/local/brian2/brian2/devices/cpp_standalone/device.py", line 989, in compile_source
raise RuntimeError(error_message)
RuntimeError: Project compilation failed (error code: 512). Consider running with "clean=True" to force a complete rebuild.
Note: specifying clean=True
won’t solve the problem: the same error will be produced, regardless.
Full traceback of error (if relevant)
N/A