Docker image for Brian 1

Brian 1 depends on Python 2.x and other outdated dependencies, so running it on modern systems has become difficult. To make it more convenient to reproduce old results obtained with Brian 1, we now provide a Docker image :whale: that you can use to run existing Brian 1 code. It is based on a Debian Linux image, and provides Brian 1.4.3, as packaged by the NeuroDebian team.

The image is hosted on the Docker hub. To use it, you either need to have docker or podman installed – if using podman, replace the docker commands below by podman.

Running a graphical interface within the docker container can be complicated, and the details how to make it work depend on the host operating system. We therefore recommend to instead either 1) only use the container image to generate and save the simulation results to disk, and then to create the plots on the host system, or 2) to use the container image to plot files to disk by adding plt.savefig(...) to the script. The container already sets the matplotlib backend to Agg by default (by setting the environment variable MPLBACKEND), necessary to avoid errors when no graphical interface is available.

To download the image and to rename it to brian1 (for convenience only, the commands below would also work directly with the full name), use:

docker pull docker.io/briansimulator/brian1.4.3
docker tag briansimulator/brian1.4.3 brian1

The following command runs myscript.py with the container image providing Brian 1 and its dependencies, mapping the current directory to the working directory in the container (this means, the script has access to all files in the current directory and its subdirectories, and can also write files there):

docker run -v "$(pwd):/workdir" brian1 python myscript.py

For Windows users using the Command Prompt (cmd.exe) instead of the Powershell, the following command will do the same thing:

docker run -v %cd%:/workdir brian1 python myscript.py

To run an interactive ipython prompt, use:

docker run -it -v "$(pwd):/workdir" brian1 ipython

Depending on your operating system, files written by the container might be owned by the user “root”, which can lead to problems later (e.g. you cannot rename/move/delete/overwrite the file on your home system without administrator rights). On Unix-based systems, you can prevent this issue by running scripts with the same user id as the host user:

docker run -u $(id -u):$(id -g) -v "$(pwd):/workdir" brian1 python myscript.py

Please let us know if you run into any issues!

1 Like

@mstimberg on almost all big clusters Docker is prohibited due to security issues and inability to talk with SLURM. The standard container program on HPC is singularity. Singularity can read the docker images but does not always interpret and run them correctly. If you haven’t tested the brian1 image in singularity, I have a working singularity environment here and can try the image. Do you have a test script to run?

Hi. I hope no-one will use Brian 1 for any kind of serious work :grimacing:, so not sure whether this is really a problem in practice… But would be great if you could try it out. Basically running any Brian 1 example, e.g. Example: COBA (misc) — Brian 1.4.4 documentation, should show whether it works or not.

~$ singularity pull docker://briansimulator/brian1.4.3
INFO:    Converting OCI blobs to SIF format
INFO:    Starting build...
Getting image source signatures
Copying blob ddad87bfbb22 done  
Copying blob e7c9a73d931d done  
Copying blob 5200ccc0ea5c done  
Copying config 17d34fd39f done  
Writing manifest to image destination
Storing signatures
2023/01/31 11:54:38  info unpack layer: sha256:e7c9a73d931db662e1ca58d2354a3cea88bbf2585ff61462c8b69ea7dc737826
2023/01/31 11:54:38  warn rootless{usr/local/man} ignoring (usually) harmless EPERM on setxattr "user.rootlesscontainers"
2023/01/31 11:54:39  info unpack layer: sha256:5200ccc0ea5c1241d7f4f0a65e8561d35f2627dc8d359ad3d22f70ab79bcbc09
2023/01/31 11:54:40  info unpack layer: sha256:ddad87bfbb22559f2dc081c3a184981ba53934d6c058ad372cc3645d875400b6
INFO:    Creating SIF file...
~$ singularity run brian1.4.3_latest.sif python br1-example.py 
INFO:    Converting SIF file to temporary sandbox...
Network construction time: 0.133754014969 seconds
Simulation running...
Simulation time: 0.684526920319 seconds
58059 excitatory spikes
14781 inhibitory spikes
INFO:    Cleaning up image...
1 Like

Great, thanks for the feedback. I’ll add a note to Brian1’s README file and will also add a mention to the Brian 2 docs :+1:

1 Like

For reference: Container image for Brian 1 — Brian 2 2.5.1.post0.dev87 documentation
I did not go into details about singularity, but at least I mention it.

1 Like