Biowulf High Performance Computing at the NIH
The Virtual Brain on Biowulf
TVB logo

The Virtual Brain Scientific Library for Python

References:

Documentation
Important Notes

Interactive job
Interactive jobs should be used for debugging, graphics, or applications that cannot be run as batch jobs.

Graphical interactive sessions

If you wish to use the graphical user interface of TVB you will need to allocate an sinteractive session, then create a tunnel to that session to access your TVB instance on your local desktop's web browser. Please refer to our tunneling instructions at our SSH tunneling page. for details.

Allocate an interactive session and run the program.
Sample session (user input in bold):

[user@biowulf]$ sinteractive
salloc.exe: Pending job allocation 46116226
salloc.exe: job 46116226 queued and waiting for resources
salloc.exe: job 46116226 has been allocated resources
salloc.exe: Granted job allocation 46116226
salloc.exe: Waiting for resource configuration
salloc.exe: Nodes cn3144 are ready for job

Created 1 generic SSH tunnel(s) from this compute node to 
biowulf for your use at port numbers defined 
in the $PORTn ($PORT1, ...) environment variables.

Please create a SSH tunnel from your workstation to these ports on biowulf.
On Linux/MacOS, open a terminal and run:

    ssh  -L 45000:localhost:45000 apptest1@biowulf.nih.gov

For Windows instructions, see https://hpc.nih.gov/docs/tunneling

[user@cn3144 ~]$ module load tvb/1.5.8
[+] Loading tvb 1.5.8 on cn3144
[user@cn3144 ~]$ tvb_start.sh

Programmatic interactive sessions

Allocate an interactive session and run the program.
Sample session (user input in bold) using an example from The Virtual Brain Tutorial (short brain simulation with region stimulation):

[user@biowulf]$ sinteractive
salloc.exe: Pending job allocation 46116226
salloc.exe: job 46116226 queued and waiting for resources
salloc.exe: job 46116226 has been allocated resources
salloc.exe: Granted job allocation 46116226
salloc.exe: Waiting for resource configuration
salloc.exe: Nodes cn3144 are ready for job

[user@cn3144 ~]$ module load tvb
[+] Loading tvb 1.5.4 on cn3144
[user@cn3144 ~]$ python
Python 2.7.15 |Anaconda, Inc.| (default, Oct 10 2018, 21:32:13) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from tvb.simulator.lab import *
>>> import numpy as numpy
>>> import matplotlib.pyplot as plt
>>> conn = connectivity.Connectivity(load_default=True)
>>> weighting = numpy.zeros((76, ))
>>> weighting[[14, 52, 11, 49]] = 0.1
>>> eqn_t = equations.PulseTrain()
>>> eqn_t.parameters['onset'] = 1.5e3
>>> eqn_t.parameters['T'] = 100.0
>>> eqn_t.parameters['tau'] = 50.0
>>> stimulus = patterns.StimuliRegion(temporal=eqn_t, connectivity=conn, weight=weighting)
>>> stimulus.configure_space()
>>> stimulus.configure_time(numpy.arange(0., 3e3, 2**-4))
>>> plot_pattern(stimulus)
>>> sim = simulator.Simulator(
...     model=models.Generic2dOscillator(a=0.3, tau=2),
...     connectivity=conn,
...     coupling=coupling.Difference(a=7e-4),
...     integrator=integrators.HeunStochastic(dt=0.5, noise=noise.Additive(nsig=5e-5)),
...     monitors=(
...         monitors.TemporalAverage(period=1.0),
...         ),
...     stimulus=stimulus,
...     simulation_length=5e3, # 1 minute simulation
... ).configure()
>>> (tavg_time, tavg_data),  = sim.run()
>>> plt.figure()
>>> plt.plot(tavg_time, tavg_data[:, 0, :, 0], 'k', alpha=0.1)
>>> plt.plot(tavg_time, tavg_data[:, 0, :, 0].mean(axis=1), 'r', alpha=1)
>>> plt.ylabel("Temporal average")
>>> plt.xlabel('Time (ms)')
>>> plt.show()
>>> import tvb.datatypes.time_series
>>> tsr = tvb.datatypes.time_series.TimeSeriesRegion(
...     data=tavg_data,
...     connectivity=conn,
...     sample_period=sim.monitors[0].period / 1000.0, 
...     sample_period_unit="s")
>>> tsr.configure()
>>> tsr
>>> import tvb.simulator.plot.timeseries_interactive as ts_int
>>> tsi = ts_int.TimeSeriesInteractive(time_series=tsr)
>>> tsi.configure()
>>> tsi.show()
>>> exit()

[user@cn3144 ~]$ exit
salloc.exe: Relinquishing job allocation 46116226
[user@biowulf ~]$

With the interactive code above you should be able to reproduce the following three graphs (stimulus pattern, temporal average of brain activity, and timeseries for all brain regions (which is the expected result as seen in the region stimulation example from the TVB tutorial:

Stimulus pattern

Temporal average

Regional timeseries

Batch job
Most jobs should be run as batch jobs.

Create a batch input file (e.g. my_tvb.sh). For example:

#!/bin/bash
module load tvb
python my_tvb_script.py

Submit this job using the Slurm sbatch command.

sbatch [--cpus-per-task=#] [--mem=#] my_tvb.sh
Swarm of Jobs
A swarm of jobs is an easy way to submit a set of independent commands requiring identical resources.

Create a swarmfile (e.g. my_tvb.swarm). For example:

python my_tvb_script.py
python my_tvb_script.py
python my_tvb_script.py
python my_tvb_script.py

Submit this job using the swarm command.

swarm -f my_tvb.swarm [-g #] [-t #] --module tvb
where
-g # Number of Gigabytes of memory required for each process (1 line in the swarm command file)
-t # Number of threads/CPUs required for each process (1 line in the swarm command file).
--module tvb Loads the tvb module for each subjob in the swarm