Installation

BrainPy is designed to run on across-platforms, including Windows, GNU/Linux and OSX. It only relies on Python libraries.

Installation with pip

You can install BrainPy from the pypi. To do so, use:

pip install brain-py

If you try to update the BrainPy version, you can use

pip install -U brain-py

If you want to install the pre-release version (the latest development version) of BrainPy, you can use:

pip install --pre brain-py

Installation from source

If you decide not to use conda or pip, you can install BrainPy from GitHub, or OpenI.

To do so, use:

pip install git+https://github.com/PKU-NIP-Lab/BrainPy

# or

pip install git+https://git.openi.org.cn/OpenI/BrainPy

Package Dependency

In order to make BrainPy work normally, users should install several dependent Python packages.

NumPy & Matplotlib

The basic function of BrainPy only relies on NumPy and Matplotlib. Install these two packages is very easy, just using pip or conda:

pip install numpy matplotlib
# or
conda install numpy matplotlib

JAX

We highly recommend you to install JAX. JAX is a high-performance JIT compiler which enables users run Python code on CPU, GPU, or TPU devices. Most functionalities of BrainPy is based on JAX.

Currently, JAX supports Linux (Ubuntu 16.04 or later) and macOS (10.12 or later) platforms. The provided binary releases of JAX for Linux and macOS systems are available at https://storage.googleapis.com/jax-releases/jax_releases.html .

To install a CPU-only version of JAX, you can run

pip install --upgrade "jax[cpu]"

If you want to install JAX with both CPU and NVidia GPU support, you must first install CUDA and CuDNN, if they have not already been installed. Next, run

pip install --upgrade "jax[cuda]" -f https://storage.googleapis.com/jax-releases/jax_releases.html

Alternatively, you can download the preferred release “.whl” file, and install it via pip:

pip install xxxx.whl

For Windows users, JAX can be installed by the following methods:

Method 1: For Windows 10+ system, you can Windows Subsystem for Linux (WSL). The installation guide can be found in WSL Installation Guide for Windows 10. Then, you can install JAX in WSL just like the installation step in Linux.

Method 2: There are several community supported Windows build for jax, please refer to the github link for more details: https://github.com/cloudhan/jax-windows-builder . Simply speaking, you can run:

# for only CPU
pip install jaxlib -f https://whls.blob.core.windows.net/unstable/index.html

# for GPU support
pip install <downloaded jaxlib>

Method 3: You can also build JAX from source.

Numba

Numba is also an excellent JIT compiler, which can accelerate your Python codes to approach the speeds of C or FORTRAN. Numba works best with NumPy. Many BrainPy modules rely on Numba for speed acceleration, such like connectivity, simulation, analysis, measurements, etc. Numba is also a suitable framework for the computation of sparse synaptic connections commonly used in the computational neuroscience project.

Numba is a cross-platform package which can be installed on Windows, Linux, and macOS. Install Numba is a piece of cake. You just need type the following commands in you terminal:

pip install numba
# or
conda install numba

SymPy

In BrainPy, several modules need the symbolic inference by SymPy. For example, Exponential Euler numerical solver needs SymPy to compute the linear part of your defined Python codes, phase plane and bifurcation analysis in dynamics analysis module needs symbolic computation from SymPy. Therefore, we highly recommend you to install sympy, just typing

pip install sympy
# or
conda install sympy