Description of problem
I have a running Brian2 code parallelized using set_device(‘cpp_standalone’, build_on_run=False) : which runs perfectly on my Ubuntu 24.04 system . Now I need to run the same on a linux cluster for harnessing the parallelization. But I run into the following error :
Number of cores: 48
WARNING OpenMP code is not yet well tested, and may be inaccurate. [brian2.devices.cpp_standalone.device.openmp]
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
brianlib/randomkit/randomkit.c:68:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
make: *** [brianlib/randomkit/randomkit.o] Error 1
make: *** Waiting for unfinished jobs…
In file included from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/c++config.h:508,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/cstdlib:41,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/stdlib.h:36,
from main.cpp:1:
/home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/os_defines.h:39:10: fatal error: features.h: No such file or directory
#include <features.h>
^~~~~~~~~~~~
In file included from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/c++config.h:508,
from
RuntimeError: Project compilation failed (error code: 512). Consider running with “clean=True” to force a complete rebuild.
[ full error message is posted in full traceback]
HELP calls.
Minimal code to reproduce problem
#!/usr/bin/env python
# coding: utf-8
from brian2 import *
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
set_device('cpp_standalone', build_on_run=False)
start_scope()
defaultclock.dt = 0.01*ms
gnaf = 140*nS
gnas = 12*nS
gkv = 6*nS
gka = 58.1*nS
gks = 8.11*nS
gl = 0.39*nS
Cm = 4*pF
#reversal potentials
ena = 58*mV
ek = -81*mV
el = -65*mV
eqs = '''
#dv/dt = (Iapp - gnaf*m**3*h*(v-ena) - gkv*n**4*(v-ek) - gka*ma**3*ha*(v-ek) - gks*ms**2*(v-ek) - gl*(v-el))/Cm : volt
dv/dt = (Iapp -inaf -inas -ikv -iks -ika - gl*(v- el))/Cm : volt
# #fast potassium current ka
ika = gka*mka**3*hka*(v-ek) : amp
dhka/dt = (hkainf - hka)/tau_hka : 1
tau_hka = 2.5*ms + (tau_hka0/(1 + exp(( v -(-62*mV))/(16*mV))) ): second
tau_hka0 = ( (90*ms - 2.5*ms) / (1 + exp(( v -(52*mV))/(15*mV))) ) : second
hkainf = 1/(1 + exp((v - (-74.7*mV))/(7*mV))) : 1
dmka/dt = (mkainf - mka)/tau_mka : 1
tau_mka = 0.35*ms + (tau_mka0/(1 + exp(( v -(-20*mV))/(12*mV))) ) : second
tau_mka0 = ( (1.65*ms - 0.35*ms) / (1 + exp(( v -(20*mV))/(20*mV))) ) : second
mkainf = 1/(1 + exp((-20.1*mV - v)/(16.1*mV))) : 1
#slow potassium current ks
iks = gks*mks**3*hks*(v-ek) : amp
dhks/dt = (hksinf - hks)/tau_hks : 1
tau_hks = 150*ms + ( (200*ms - 150*ms) / (1 + exp(( v -(52*mV))/(15*mV))) ) : second
hksinf = 1/(1 + exp((v - (-74.7*mV))/(7*mV))) : 1
dmks/dt = (mksinf - mks)/tau_mks : 1
tau_mks = 0.5*ms + ( (5.0*ms - 0.5*ms) / (1 + exp(( v -(20*mV))/(20*mV))) ) : second
mksinf = 1/(1 + exp((-20.1*mV - v)/(16.1*mV))) : 1
#potassium current kv
ikv = gkv*mkv**4*(v-ek) : amp
dmkv/dt = (mkvinf - mkv)/tau_mkv : 1
tau_mkv = 1.85*ms + ( (3.53*ms - 1.85*ms) / (1 + exp(( v -(45*mV))/(13.71*mV))) ) : second
mkvinf = 1/(1 + exp((-37.6*mV - v)/(27.24*mV))) : 1
#slow sodium current
inas = gnas*mnas**3*hnas*(v-ena) : amp
dhnas/dt = (hnasinf - hnas)/tau_hnas : 1
tau_hnas = 1.9*ms + ( (12.24*ms - 1.9*ms) / (1 + exp(( v -(-32.6*mV))/(8.0*mV))) ) : second
hnasinf = 1/(1 + exp((v - (-51.4*mV))/(5.9*mV))) : 1
dmnas/dt = (mnasinf - mnas)/tau_mnas : 1
tau_mnas = 0.093*ms + ( (0.83*ms - 0.093*ms) / (1 + exp(( v -(-20.3*mV))/(6.45*mV))) ) : second
mnasinf = 1/(1 + exp((-30.1*mV - v)/(6.65*mV))) : 1
#fast sodium current
inaf = gnaf*mnaf**3*hnaf*(v-ena) : amp
dhnaf/dt = (hnafinf - hnaf)/tau_hnaf : 1
tau_hnaf = 0.12*ms + ( (1.66*ms - 0.12*ms) / (1 + exp(( v -(-8.03*mV))/(8.69*mV))) ) : second
hnafinf = 1/(1 + exp((v - (-51.4*mV))/(5.9*mV))) : 1
dmnaf/dt = (mnafinf - mnaf)/tau_mnaf : 1
tau_mnaf = 0.093*ms + ( (0.83*ms - 0.093*ms) / (1 + exp(( v -(-20.3*mV))/(6.45*mV))) ) : second
mnafinf = 1/(1 + exp((-30.1*mV - v)/(6.65*mV))) : 1
'''
neuron = NeuronGroup(5000, eqs, method='rk4')
neuron.v = '-80*mV*rand()*i'
neuron.hnaf = 1.0
neuron.mnaf = 0.0
neuron.hnas = 1.0
neuron.mnas = 0.0
neuron.mkv = 0.0
neuron.mks = 0.0
neuron.hks = 1.0
neuron.hka = 1.0
neuron.mka = 0.0
#record the membrane potential for all neurons
#M = StateMonitor(neuron, 'v', record=True)
#can also record the gating variables
M = StateMonitor(neuron, ['v'], record=True)
Iapp = 0*pA
run(20*ms, report='text')
Iapp = 18*pA
run(2*second, report='text')
Iapp = 0*pA
run(50*ms, report='text')
#get the number of cores using the multiprocessing module
import multiprocessing
num_cores = multiprocessing.cpu_count()
print('Number of cores:', num_cores)
prefs.devices.cpp_standalone.openmp_threads = num_cores
device.build()
#plot all the neurons
plt.figure(figsize=(12, 6))
for i in range(10):
plt.plot(M.t/ms, M.v[i]/mV)
plt.xlabel('Time (ms)')
plt.ylabel('v (mV)')
plt.ylim(-80,20)
plt.savefig('neuron.png')
show()
#save the data as .npy file
np.save('v.npy', M.v)
np.save('t.npy', M.t)
def spike_counter2(t,V,th, sparse = 100) :
V = np.array(V)
t = np.array(t)
#sparse the V and t array to find the spike times
V = V[::sparse]
t = t[::sparse]
ind1 = []
for i in range(np.shape(V)[0] -1) :
if ((V[i] - th) <= 0.0 and (V[i+1] - th) > 0.0 ) :
ind1.append(i)
arr = t[ind1]
return arr
def rastor_plotter(nl,t,th,dpi = 100, size = (20,10), color = "black") :
spike_times = []
for i in range(np.shape(nl)[0]) :
spike_times.append(spike_counter2(t,nl[i],th))
# Plot the raster plot
figure(figsize=size, dpi=dpi)
plt.eventplot(spike_times, lineoffsets=range(np.shape(nl)[0]), linelengths=4.0,color=color)
plt.xlabel('Time (seconds)')
plt.ylabel('Neuron #')
#store the spike times
#np.save('spike_times.npy', spike_times)
return figure
#plot the rastor plot
rastor_plotter(M.v/mV,M.t/ms,-20, dpi = 100, size = (20,10), color = "blue")
plt.savefig('rastor_plot.png')
plt.show()
What you have already tried
I have tried using different versions of python using conda. (3.10,3.11,3.13)
Note that I did install brian2 using pip not conda
I also tried force = True, it does’nt work
Expected output (if relevant)
Actual output (if relevant)
Full traceback of error (if relevant)
Number of cores: 48
WARNING OpenMP code is not yet well tested, and may be inaccurate. [brian2.devices.cpp_standalone.device.openmp]
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
brianlib/randomkit/randomkit.c:68:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
make: *** [brianlib/randomkit/randomkit.o] Error 1
make: *** Waiting for unfinished jobs…
In file included from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/c++config.h:508,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/cstdlib:41,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/stdlib.h:36,
from main.cpp:1:
/home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/os_defines.h:39:10: fatal error: features.h: No such file or directory
#include <features.h>
^~~~~~~~~~~~
In file included from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/c++config.h:508,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/cstdlib:41,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/stdlib.h:36,
from run.cpp:1:
/home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/os_defines.h:39:10: fatal error: features.h: No such file or directory
#include <features.h>
^~~~~~~~~~~~
compilation terminated.
compilation terminated.
make: *** [main.o] Error 1
make: *** [run.o] Error 1
In file included from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/c++config.h:508,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/bits/stl_algobase.h:59,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/vector:60,
from ./synapses_classes.h:5,
from ./objects.h:5,
from code_objects/neurongroup_stateupdater_codeobject_2.cpp:2:
/home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/os_defines.h:39:10: fatal error: features.h: No such file or directory
#include <features.h>
^~~~~~~~~~~~
compilation terminated.
In file included from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/c++config.h:508,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/bits/stl_algobase.h:59,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/vector:60,
from synapses_classes.h:5,
from objects.h:5,
from objects.cpp:2:
/home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/os_defines.h:39:10: fatal error: features.h: No such file or directory
#include <features.h>
^~~~~~~~~~~~
make: *** [code_objects/neurongroup_stateupdater_codeobject_2.o] Error 1
compilation terminated.
In file included from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/c++config.h:508,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/bits/stl_algobase.h:59,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/vector:60,
from ./synapses_classes.h:5,
from ./objects.h:5,
from code_objects/statemonitor_codeobject.cpp:2:
/home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/os_defines.h:39:10: fatal error: features.h: No such file or directory
#include <features.h>
^~~~~~~~~~~~
compilation terminated.
In file included from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/c++config.h:508,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/bits/stl_algobase.h:59,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/vector:60,
from network.h:5,
from network.cpp:2:
/home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/os_defines.h:39:10: fatal error: features.h: No such file or directory
#include <features.h>
^~~~~~~~~~~~
In file included from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/c++config.h:508,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/bits/stl_algobase.h:59,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/vector:60,
from ./synapses_classes.h:5,
from ./objects.h:5,
from code_objects/neurongroup_stateupdater_codeobject.cpp:2:
/home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/os_defines.h:39:10: fatal error: features.h: No such file or directory
#include <features.h>
^~~~~~~~~~~~
In file included from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/c++config.h:508,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/bits/stl_algobase.h:59,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/vector:60,
from ./synapses_classes.h:5,
from ./objects.h:5,
from code_objects/neurongroup_stateupdater_codeobject_1.cpp:2:
/home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/os_defines.h:39:10: fatal error: features.h: No such file or directory
#include <features.h>
^~~~~~~~~~~~
compilation terminated.
compilation terminated.
compilation terminated.
In file included from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/c++config.h:508,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/bits/stl_algobase.h:59,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/vector:60,
from ./synapses_classes.h:5,
from ./objects.h:5,
from code_objects/statemonitor_codeobject_2.cpp:2:
/home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/os_defines.h:39:10: fatal error: features.h: No such file or directory
#include <features.h>
^~~~~~~~~~~~
In file included from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/c++config.h:508,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/bits/stl_algobase.h:59,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/vector:60,
from ./synapses_classes.h:5,
from ./objects.h:5,
from code_objects/neurongroup_group_variable_set_conditional_codeobject.cpp:2:
/home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/os_defines.h:39:10: fatal error: features.h: No such file or directory
#include <features.h>
^~~~~~~~~~~~
In file included from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/c++config.h:508,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/bits/stl_algobase.h:59,
from /home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/vector:60,
from ./synapses_classes.h:5,
from ./objects.h:5,
from code_objects/statemonitor_codeobject_1.cpp:2:
/home/opt_ohpc_pub/compiler/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/os_defines.h:39:10: fatal error: features.h: No such file or directory
#include <features.h>
^~~~~~~~~~~~
compilation terminated.
compilation terminated.
compilation terminated.
make: *** [objects.o] Error 1
make: *** [code_objects/statemonitor_codeobject.o] Error 1
make: *** [network.o] Error 1
make: *** [code_objects/neurongroup_stateupdater_codeobject_1.o] Error 1
make: *** [code_objects/neurongroup_stateupdater_codeobject.o] Error 1
make: *** [code_objects/neurongroup_group_variable_set_conditional_codeobject.o] Error 1
make: *** [code_objects/statemonitor_codeobject_2.o] Error 1
make: *** [code_objects/statemonitor_codeobject_1.o] Error 1
cc -c -o brianlib/randomkit/randomkit.o brianlib/randomkit/randomkit.c
g++ -c -Wno-write-strings -Ibrianlib/randomkit -I/home/apps/anaconda3/include -w -O3 -ffast-math -fno-finite-math-only -march=native -std=c++11 -I. -fopenmp code_objects/neurongroup_group_variable_set_conditional_codeobject.cpp -o code_objects/neurongroup_group_variable_set_conditional_codeobject.o
g++ -c -Wno-write-strings -Ibrianlib/randomkit -I/home/apps/anaconda3/include -w -O3 -ffast-math -fno-finite-math-only -march=native -std=c++11 -I. -fopenmp code_objects/neurongroup_stateupdater_codeobject.cpp -o code_objects/neurongroup_stateupdater_codeobject.o
g++ -c -Wno-write-strings -Ibrianlib/randomkit -I/home/apps/anaconda3/include -w -O3 -ffast-math -fno-finite-math-only -march=native -std=c++11 -I. -fopenmp code_objects/neurongroup_stateupdater_codeobject_1.cpp -o code_objects/neurongroup_stateupdater_codeobject_1.o
g++ -c -Wno-write-strings -Ibrianlib/randomkit -I/home/apps/anaconda3/include -w -O3 -ffast-math -fno-finite-math-only -march=native -std=c++11 -I. -fopenmp code_objects/neurongroup_stateupdater_codeobject_2.cpp -o code_objects/neurongroup_stateupdater_codeobject_2.o
g++ -c -Wno-write-strings -Ibrianlib/randomkit -I/home/apps/anaconda3/include -w -O3 -ffast-math -fno-finite-math-only -march=native -std=c++11 -I. -fopenmp code_objects/statemonitor_codeobject.cpp -o code_objects/statemonitor_codeobject.o
g++ -c -Wno-write-strings -Ibrianlib/randomkit -I/home/apps/anaconda3/include -w -O3 -ffast-math -fno-finite-math-only -march=native -std=c++11 -I. -fopenmp code_objects/statemonitor_codeobject_1.cpp -o code_objects/statemonitor_codeobject_1.o
g++ -c -Wno-write-strings -Ibrianlib/randomkit -I/home/apps/anaconda3/include -w -O3 -ffast-math -fno-finite-math-only -march=native -std=c++11 -I. -fopenmp code_objects/statemonitor_codeobject_2.cpp -o code_objects/statemonitor_codeobject_2.o
g++ -c -Wno-write-strings -Ibrianlib/randomkit -I/home/apps/anaconda3/include -w -O3 -ffast-math -fno-finite-math-only -march=native -std=c++11 -I. -fopenmp main.cpp -o main.o
g++ -c -Wno-write-strings -Ibrianlib/randomkit -I/home/apps/anaconda3/include -w -O3 -ffast-math -fno-finite-math-only -march=native -std=c++11 -I. -fopenmp network.cpp -o network.o
g++ -c -Wno-write-strings -Ibrianlib/randomkit -I/home/apps/anaconda3/include -w -O3 -ffast-math -fno-finite-math-only -march=native -std=c++11 -I. -fopenmp objects.cpp -o objects.o
g++ -c -Wno-write-strings -Ibrianlib/randomkit -I/home/apps/anaconda3/include -w -O3 -ffast-math -fno-finite-math-only -march=native -std=c++11 -I. -fopenmp run.cpp -o run.o
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_0ftv39n4.log Additionally, you can also include a copy of the script that was run, available at: /tmp/brian_script_w4f4ufs1.py You can also include a copy of the redirected std stream outputs, available at ‘/tmp/brian_stdout_lnw14o60.log’ and ‘/tmp/brian_stderr_2capj6w7.log’. Thanks! [brian2]
Traceback (most recent call last):
File “KC_in_brian2_parallel.py”, line 137, in
device.build()
File “/home/apps/anaconda3/lib/python3.7/site-packages/brian2/devices/cpp_standalone/device.py”, line 1290, in build
self.compile_source(directory, compiler, debug, clean)
File “/home/apps/anaconda3/lib/python3.7/site-packages/brian2/devices/cpp_standalone/device.py”, line 1031, in compile_source
raise RuntimeError(error_message)
RuntimeError: Project compilation failed (error code: 512). Consider running with “clean=True” to force a complete rebuild.