Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@
/pygenn.egg-info/
.vscode/
/pygenn/share/
.idea
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,11 @@ clean:
@# Delete libGeNN
@rm -f $(LIBGENN)
@rm -f $(BACKEND_LIBS)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be cool and convenient to have a makefile rule to setup an interactive pygenn container with -it, and bind host pwd to some directory (e.g. 'workspace') in the working directory of the container. Just for people who don't want to use jupyter.

.PHONY docker-build:
docker-build:
@docker build -f ./build_steps/Dockerfile -t pygenn:latest .

.PHONY docker-jupyter:
docker-jupyter:
@docker run -p 127.0.0.1:8888:8888/tcp -v '$(CURDIR)'/pygenn/notebooks:/root/pygenn/notebooks pygenn jupyter notebook --ip 0.0.0.0 --no-browser
10 changes: 10 additions & 0 deletions build_steps/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.git
build
dist
docs
doxygenn
lib
obj*
tests
userproject
!userproject/include
26 changes: 26 additions & 0 deletions build_steps/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM nvidia/cuda:11.5.0-devel-ubuntu20.04

ARG USERNAME="pygennuser"
ARG PYGENN_HOME="/root"

RUN apt-get update && \
apt-get upgrade -y

RUN apt-get install -yq --no-install-recommends curl vim python3-dev python3-pip

RUN pip install swig numpy jupyter

ENV CUDA_PATH=/usr/local/cuda-11.5
ENV HOME=${PYGENN_HOME}
ENV USERNAME=${USERNAME}

WORKDIR ${HOME}

COPY . ${HOME}

RUN adduser --disabled-password --gecos "" $USERNAME && chown -R ${USERNAME}:${USERNAME} "/root"

RUN make DYNAMIC=1 LIBRARY_DIRECTORY=${HOME}/pygenn/genn_wrapper/
RUN python3 setup.py develop

USER $USERNAME
28 changes: 28 additions & 0 deletions build_steps/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: "3.4"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite see why docker compose is required....I thought it was intended to combine together multiple containers whereas, couldn't what you do here be achieved with a single docker run incantation?

Also, more fundamentally, the way I imagine the GeNN docker image being used is that it would be hosted on Dockerhub (probably produced by CI when we make releases/merge master) so users wouldn't have to checkout our git repro and hence wouldn't have access to the docker compose script outside of the container.

Again, I may be missing things....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, it facilitates having multiple containers interacting together. I only used it as I find it helpful to set up port bindings, volumes, health checks, etc in a configurable way that is easy to use (and was used only to launch jupyter).

However, if it is not going to be useful for extendability then maybe, as you say, a command such as docker run -p 127.0.0.1:8888:8888/tcp -v '$(CURDIR)'/pygenn/notebooks:/root/pygenn/notebooks pygenn jupyter notebook --ip 0.0.0.0 --no-browser is better suited. I have added this to the makefile (as make docker-jupyter) and can delete the docker-compose.yml?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for saving such brutally long command lines, docker compose seems like a good idea (especially as it's optional).


services:
pygenn:
image: pygenn:latest
container_name: pygenn
restart: always
ports:
- 8888:8888
volumes:
- ../pygenn/notebooks:/root/pygenn/notebooks
networks:
- pygenn
command: /bin/bash /root/build/entrypoint.sh
user: pygennuser:pygennuser
healthcheck:
test: ["CMD", "curl", "-f", "host.docker.internal:8888"]
interval: 30s
timeout: 10s
retries: 5
start_period: 5m

volumes:
pygenn_notebooks:

networks:
pygenn:
driver: bridge
2 changes: 2 additions & 0 deletions build_steps/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
jupyter notebook --ip 0.0.0.0 --no-browser
5 changes: 5 additions & 0 deletions pygenn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ PyGeNN wraps the C++ GeNN API using SWIG, allowing GeNN to be used either direct
- Navigate to the GeNN directory and build GeNN as a dll using ``msbuild genn.sln /t:Build /p:Configuration=Release_DLL`` (if you don't have CUDA installed, building the CUDA backend will fail but it should still build the CPU backend).
- Copy the newly built DLLs into pygenn using ``copy /Y lib\genn*Release_DLL.* pygenn\genn_wrapper``
- Build the Python extension with setup tools using ``python setup.py develop`` command

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably add pygenn/README.md documentation for the docker-jupyter option, plus for the interactive container rule mentioned above, if implemented.

### Docker
- `make docker-build` (from project root) to build Docker image
- `docker-compose up` (from /buildsteps) to launch the container. This will start a Jupyter notebook that can be accessed at `localhost:8888` with the token printed to screen
- Note that a volume is created so that notebooks created in `pygenn/notebooks` will be persisted
Empty file added pygenn/notebooks/.gitkeep
Empty file.