Description of problem
Hello everyone. I am running a very long simulation that is RAM-intensive. In my current code, I am not using the cpp standalone code, but I am translating my model to run on a GPU using the brian2cuda
module. Currently, I have code that looks something like the code snippet below (for brevity, equations and the total number of groups/monitors are omitted, as the specific equations do not matter in this case).
The problem I am facing is during the `np.save()’ command, as Brian2 mentions that in standalone mode it is not possible to access the values of state variables before the simulation has been run (NotImplementedError).
I would say that I am a bit confused with the documentation because I do not wish to run independent simulations, but rather split on a single simulation into multiple run()
calls to optimize resource usage. Unfortunately, the model has tens of thousands of neurons (and millions of synapses) and it would be impossible to run 10-second simulations in one go, especially if I am to monitor all important information. Any advice or pointers to the right direction are more than welcome! Thanks in advance.
Minimal code to reproduce problem
# Neuron Group initialization
G = NeuronGroup(...)
# Make a network and add the group
net = Network()
net.add(G)
# Preparation for simulations
t_run = 10 * second
t_step = 0.1 * second
start = time.time()
while t_run > 0*second
# Volatile monitor Initialization
M = StateMonitor(G, 'v', record=True)
net.add(M)
# Run a simulation step
net.run(t_step, report='text', report_period=5*second, profile=True)
t_run -= t_step
# Write data to disk
with open('data.txt', 'a') as f:
np.savetxt(f, M.v, fmt='%.8f')
f.write('\n')
# Remove the monitor from the net and delete it
net.remove(M)
del M
# Mandatory build call for multiple run() calls
device.build(directory='output', compile=True, run=True, debug=False
What you have already tried
I followed the solutions provided here and on the Brian2 User’s Guide - Freeing up memory in long recordings.