Skip to content

Commit

Permalink
Merge pull request #496 from ztqakita/master
Browse files Browse the repository at this point in the history
[docs] add BrainPy docker and docs
  • Loading branch information
chaoming0625 authored Sep 13, 2023
2 parents 248c9e9 + e28c1c6 commit 5430c11
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 11 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Docker

on:
release:
types: [published]
pull_request:
paths:
- docker/**
- .github/workflows/docker.yml


jobs:
docker-build-push:
if: |
github.repository_owner == 'brainpy' ||
github.event_name != 'release'
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- context: "docker/"
base: "brainpy/brainpy"
env:
TARGET_PLATFORMS: linux/amd64
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
DOCKER_TAG_NAME: |
${{
(github.event_name == 'release' && github.event.release.tag_name) ||
'pull-request-test'
}}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker Build & Push (version tag)
uses: docker/build-push-action@v4
with:
context: ${{ matrix.context }}
tags: ${{ matrix.base }}:${{ env.DOCKER_TAG_NAME }}
push: ${{ github.event_name != 'pull_request' }}
platforms: ${{ env.TARGET_PLATFORMS }}

- name: Docker Build & Push (latest tag)
if: |
(github.event_name == 'release' && ! github.event.release.prerelease)
uses: docker/build-push-action@v4
with:
context: ${{ matrix.context }}
tags: ${{ matrix.base }}:latest
push: ${{ github.event_name != 'pull_request' }}
platforms: ${{ env.TARGET_PLATFORMS }}
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@ $ pip install brainpy brainpylib -U
For detailed installation instructions, please refer to the documentation: [Quickstart/Installation](https://brainpy.readthedocs.io/en/latest/quickstart/installation.html)


### Using BrainPy with docker

We provide a docker image for BrainPy. You can use the following command to pull the image:
```bash
$ docker pull brainpy/brainpy:latest
```

Then, you can run the image with the following command:
```bash
$ docker run -it --platform linux/amd64 brainpy/brainpy:latest
```

### Using BrainPy with Binder

We provide a Binder environment for BrainPy. You can use the following button to launch the environment:

[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/brainpy/BrainPy-binder/main)

## Ecosystem

- **[BrainPy](https://github.com/brainpy/BrainPy)**: The solution for the general-purpose brain dynamics programming.
Expand Down
23 changes: 23 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM ubuntu:22.04

ENV TZ=Asia/Dubai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt update
RUN apt install -y --no-install-recommends software-properties-common

RUN apt update && apt install -y python3-pip

RUN ln -sf /usr/bin/python3.10 /usr/bin/python && \
ln -sf /usr/bin/pip3 /usr/bin/pip


RUN pip --no-cache-dir install --upgrade pip && \
pip --no-cache-dir install --upgrade setuptools && \
pip --no-cache-dir install --upgrade wheel

ADD . /usr/src/app
WORKDIR /usr/src/app

RUN pip --no-cache-dir install --upgrade "jax[cpu]"
RUN pip --no-cache-dir install --upgrade -r requirements.txt
16 changes: 16 additions & 0 deletions docker/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
numpy
tqdm
msgpack
matplotlib>=3.4
jax
jaxlib
scipy>=1.1.0
brainpy
brainpylib
brainpy_datasets
h5py
pathos

# test requirements
pytest
absl-py
32 changes: 21 additions & 11 deletions docs/quickstart/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -197,33 +197,43 @@ Dependency 3: brainpylib
------------------------

Many customized operators in BrainPy are implemented in ``brainpylib``.
``brainpylib`` can also be installed from https://www.brainpylib/index.html according to your CUDA version.
``brainpylib`` can also be installed from pypi according to your devices.
For windows, Linux and MacOS users, ``brainpylib`` supports CPU operators.
You can install CPU-version `brainpylib` by:

.. code-block:: bash
# CPU installation
pip install --upgrade brainpylib
For Nvidia GPU users, ``brainpylib`` only support Linux system and WSL2 subsystem. You can install the CUDA-version by using:

.. code-block:: bash
# CUDA 12 installation
pip install --upgrade "brainpylib[cuda12]" -f https://www.brainpylib/index.html
pip install --upgrade brainpylib-cu12x
.. code-block:: bash
# CUDA 11 installation
pip install --upgrade "brainpylib[cuda11]" -f https://www.brainpylib/index.html
pip install --upgrade brainpylib-cu11x
For windows, Linux and MacOS users, ``brainpylib`` supports CPU operators.
Running BrainPy with docker
------------------------

For CUDA users, ``brainpylib`` only support GPU on Linux platform. You can install GPU version ``brainpylib``
on Linux through ``pip install brainpylib`` too.
If you want to use BrainPy in docker, you can use the following command to pull the docker image:

.. code:: bash
Installation from docker
------------------------
docker pull brainpy/brainpy:latest
If you want to use BrainPy in docker, you can use the following command
to install BrainPy:
You can then run the docker image by:

.. code:: bash
docker pull ztqakita/brainpy
docker run -it --platform linux/amd64 brainpy/brainpy:latest
Please notice that BrainPy docker image is based on the `ubuntu22.04` image, so it only support CPU version of BrainPy.


Running BrainPy online with binder
Expand Down

0 comments on commit 5430c11

Please sign in to comment.