-
Notifications
You must be signed in to change notification settings - Fork 77
build: Dockerfile and docker-compose to launch notebook with pygenn resolves genn-team/genn#546 #548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: Dockerfile and docker-compose to launch notebook with pygenn resolves genn-team/genn#546 #548
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,3 +27,4 @@ | |
| /pygenn.egg-info/ | ||
| .vscode/ | ||
| /pygenn/share/ | ||
| .idea | ||
| 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 |
| 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" | ||
jamesturner246 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| RUN make DYNAMIC=1 LIBRARY_DIRECTORY=${HOME}/pygenn/genn_wrapper/ | ||
| RUN python3 setup.py develop | ||
|
|
||
| USER $USERNAME | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| version: "3.4" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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....
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment.
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 hostpwdto some directory (e.g. 'workspace') in the working directory of the container. Just for people who don't want to use jupyter.