Description of problem
Reinitializing the device/rebuilding under C++ standalone code generation with multiple runs seems to cause some issue with linked dependencies such as mkl. I get “symbol lookup error: /opt/intel/mkl/lib/intel64/libmkl_intel_thread.so: undefined symbol: floor” followed by a RuntimeError on the second execution (fine on the first)
Minimal code to reproduce problem
import os, sys, warnings
import numpy as np
import random as pyrandom
from brian2 import *
set_device("cpp_standalone", build_on_run=False)
def example_sim(tau):
device = get_device()
device.reinit()
device.activate(build_on_run=False)
num_inputs = 100
input_rate = 10*Hz
weight = 0.1
tau *= ms
# Construct the network each time
P = PoissonGroup(num_inputs, rates=input_rate)
eqs = '''
dv/dt = -v/tau : 1
'''
G = NeuronGroup(1, eqs, threshold='v>1', reset='v=0', method='exact')
S = Synapses(P, G, on_pre='v += weight')
S.connect()
M = SpikeMonitor(G)
# Run it and store the output firing rate in the list
run(1*second)
device.build(directory='output', clean=True, compile=True, run=True, debug=False)
if __name__ == "__main__":
print("Simulation 1")
example_sim(5)
print("Simulation 2")
example_sim(50)
Expected behavior
Run both simulations
Actual behavior
Runs Simulation 1, prints “Simulation 2” but then
sh: symbol lookup error: /opt/intel/mkl/lib/intel64/libmkl_intel_thread.so: undefined symbol: floor
sh: symbol lookup error: /opt/intel/mkl/lib/intel64/libmkl_intel_thread.so: undefined symbol: floor
ERROR Brian 2 encountered an unexpected error. If you think this is a bug in Brian 2, please report this issue either to the discourse forum at <http://brian.discourse.group/>, 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_mfx1kirh.log Additionally, you can also include a copy of the script that was run, available at: /tmp/brian_script_0ydeexkq.py You can also include a copy of the redirected std stream outputs, available at /tmp/brian_stdout_b3wjq575.log and /tmp/brian_stderr_1s3ehowt.log Thanks! [brian2]
Traceback (most recent call last):
File "bug_reproduce.py", line 33, in <module>
example_sim(50)
File "bug_reproduce.py", line 27, in example_sim
device.build(directory='output', clean=True, compile=True, run=True, debug=False)
File "/home/zhenrui/anaconda3/envs/lab3/lib/python3.7/site-packages/brian2/devices/cpp_standalone/device.py", line 1254, in build
self.compile_source(directory, compiler, debug, clean)
File "/home/zhenrui/anaconda3/envs/lab3/lib/python3.7/site-packages/brian2/devices/cpp_standalone/device.py", line 990, in compile_source
raise RuntimeError(error_message)
RuntimeError: Project compilation failed (error code: 32512).