summaryrefslogtreecommitdiffstats
path: root/biomedisa
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2018-12-13 00:05:49 +0100
committerSuren A. Chilingaryan <csa@suren.me>2018-12-13 00:05:49 +0100
commit9c3d5c48694db1018d50aa85acad434f47e5ed0b (patch)
treebee24b887c12d1abaa4d942525a6c1d304dd200d /biomedisa
downloadbiomedisa-9c3d5c48694db1018d50aa85acad434f47e5ed0b.tar.gz
biomedisa-9c3d5c48694db1018d50aa85acad434f47e5ed0b.tar.bz2
biomedisa-9c3d5c48694db1018d50aa85acad434f47e5ed0b.tar.xz
biomedisa-9c3d5c48694db1018d50aa85acad434f47e5ed0b.zip
Initial import
Diffstat (limited to 'biomedisa')
-rw-r--r--biomedisa/Dockerfile49
-rw-r--r--biomedisa/Makefile48
-rwxr-xr-xbiomedisa/docker-entrypoint.sh16
-rwxr-xr-xbiomedisa/run-queues.sh9
-rw-r--r--biomedisa/supervisor/supervisord-cpu.conf27
-rw-r--r--biomedisa/supervisor/supervisord-gpu.conf32
-rwxr-xr-xbiomedisa/tests/test.sh4
7 files changed, 185 insertions, 0 deletions
diff --git a/biomedisa/Dockerfile b/biomedisa/Dockerfile
new file mode 100644
index 0000000..6666be7
--- /dev/null
+++ b/biomedisa/Dockerfile
@@ -0,0 +1,49 @@
+#FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04
+FROM nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
+MAINTAINER Suren A. Chilingaryan <csa@suren.me>
+
+# Install Devel & Python
+RUN apt-get update -qq \
+ && apt-get install --no-install-recommends -y \
+ git pkg-config netcat supervisor \
+ telnet iputils-ping dnsutils \
+ python python-dev python-pip python-setuptools python-virtualenv python-wheel python-numpy python-scipy python-h5py python-yaml python-pydot python-matplotlib libopenblas-base
+
+# Install Keras + Tensor Flow
+ARG TENSORFLOW_VERSION=1.12.0
+ARG TENSORFLOW_DEVICE=gpu
+ARG TENSORFLOW_APPEND=_gpu
+
+ARG KERAS_VERSION=2.2.4
+ENV KERAS_BACKEND=tensorflow
+
+RUN pip --no-cache-dir install \
+ https://storage.googleapis.com/tensorflow/linux/${TENSORFLOW_DEVICE}/tensorflow${TENSORFLOW_APPEND}-${TENSORFLOW_VERSION}-cp27-none-linux_x86_64.whl
+
+RUN pip --no-cache-dir install --no-dependencies \
+ git+https://github.com/fchollet/keras.git@${KERAS_VERSION}
+
+ADD tests/ /root/tests
+
+# install dependencies from debian packages
+RUN apt-get install --no-install-recommends -y \
+ mc \
+ libsm6 libxrender-dev \
+ openmpi-bin openmpi-doc libopenmpi-dev \
+ python-gdcm python-mysqldb
+
+# upgrade pip
+RUN pip --no-cache-dir install --upgrade pip
+
+# install dependencies from python packages
+RUN pip --no-cache-dir install \
+ setuptools==39.1.0 numpy==1.14.5 tifffile==0.14.0 SimpleParse==2.1.1 redis==2.10.6 rq==0.12 \
+ scipy weave scikit-image opencv-python h5py pydicom Pillow django mpi4py pycuda
+
+COPY supervisor/*.conf /etc/
+COPY *-entrypoint.sh /
+COPY run-*.sh /
+ENTRYPOINT ["/docker-entrypoint.sh"]
+
+ENV BIOMEDISA_DEVICE=${TENSORFLOW_DEVICE}
+CMD /usr/bin/supervisord -c /etc/supervisord-${BIOMEDISA_DEVICE}.conf
diff --git a/biomedisa/Makefile b/biomedisa/Makefile
new file mode 100644
index 0000000..c14b89e
--- /dev/null
+++ b/biomedisa/Makefile
@@ -0,0 +1,48 @@
+all: build
+#install: push
+
+.PHONY: rebuild build push start stop restart bash
+
+build: Dockerfile
+ docker build --tag chsa/biomedisa:latest .
+
+rebuild: Dockerfile
+ docker build --no-cache --tag chsa/biomedisa:latest .
+
+#push: build
+# docker push chsa/biomedisa:latest
+
+start: build
+ @if [ `docker ps | grep adei-mysql | wc -l` -eq 0 ]; then \
+ if [ `docker ps -a | grep adei-mysql | wc -l` -eq 0 ]; then \
+ docker run --name adei-mysql -p 53306:3306/tcp -e MYSQL_ROOT_PASSWORD="adei" -e MYSQL_DATABASE="adei" -e MYSQL_USER="adei" -e MYSQL_PASSWORD="adei" -d mysql:5.7 ;\
+ else \
+ docker start adei-mysql ;\
+ fi ;\
+ fi ;\
+ if [ `docker ps | grep chsa/adei | wc -l` -eq 0 ]; then \
+ if [ `docker ps -a | grep adei-full | wc -l` -gt 0 ]; then \
+ echo "Removing the stalled copy..." ;\
+ docker rm adei-full ;\
+ fi ;\
+ docker run -p 8000:80 --name adei-full --link adei-mysql:adei-mysql -e ADEI_PORTS=8000 -t -d chsa/adei:latest ;\
+ else \
+ echo "Already running..." ;\
+ fi
+
+stop:
+ @if [ `docker ps | grep adei-full | wc -l` -gt 0 ]; then \
+ docker stop adei-full ;\
+ docker rm adei-full ;\
+ fi
+
+stop_mysql: stop
+ docker stop adei-mysql
+
+restart:
+ make stop
+ make start
+
+bash: build
+ docker run --runtime=nvidia -it chsa/biomedisa /bin/bash
+# docker exec -it chsa/biomedisa /bin/bash
diff --git a/biomedisa/docker-entrypoint.sh b/biomedisa/docker-entrypoint.sh
new file mode 100755
index 0000000..a0f9cba
--- /dev/null
+++ b/biomedisa/docker-entrypoint.sh
@@ -0,0 +1,16 @@
+#! /bin/bash
+
+set -e
+
+export PYTHONPATH=/biomedisa:${PYTHONPATH}
+export DJANGO_SETTINGS_MODULE=biomedisa.settings
+
+if ! whoami &> /dev/null; then
+ if [ -w /etc/passwd ]; then
+ echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd
+ fi
+fi
+
+cd "/biomedisa"
+echo "Running: $@"
+exec "$@"
diff --git a/biomedisa/run-queues.sh b/biomedisa/run-queues.sh
new file mode 100755
index 0000000..a531b3b
--- /dev/null
+++ b/biomedisa/run-queues.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+# start background workers
+rq worker -u http://redis rq worker first_queue &
+rq worker -u http://redis rq worker slices &
+rq worker -u http://redis rq worker acwe &
+rq worker -u http://redis rq worker cleanup &
+rq worker -u http://redis rq worker share_notification &
+rq worker -u http://redis rq worker stop_job &
diff --git a/biomedisa/supervisor/supervisord-cpu.conf b/biomedisa/supervisor/supervisord-cpu.conf
new file mode 100644
index 0000000..c942d7d
--- /dev/null
+++ b/biomedisa/supervisor/supervisord-cpu.conf
@@ -0,0 +1,27 @@
+[supervisord]
+nodaemon=true
+
+[program:slices]
+command=rq worker -u http://redis rq worker slices
+autorestart=true
+exitcodes=0
+
+[program:acwe]
+command=rq worker -u http://redis rq worker acwe
+autorestart=true
+exitcodes=0
+
+[program:cleanup]
+command=rq worker -u http://redis rq worker cleanup
+autorestart=true
+exitcodes=0
+
+[program:share_notification]
+command=rq worker -u http://redis rq worker share_notification
+autorestart=true
+exitcodes=0
+
+[program:stop_job]
+command=rq worker -u http://redis rq worker stop_job
+autorestart=true
+exitcodes=0
diff --git a/biomedisa/supervisor/supervisord-gpu.conf b/biomedisa/supervisor/supervisord-gpu.conf
new file mode 100644
index 0000000..94323d5
--- /dev/null
+++ b/biomedisa/supervisor/supervisord-gpu.conf
@@ -0,0 +1,32 @@
+[supervisord]
+nodaemon=true
+
+[program:first]
+command=rq worker -u http://redis rq worker first_queue
+autorestart=true
+exitcodes=0
+
+[program:slices]
+command=rq worker -u http://redis rq worker slices
+autorestart=true
+exitcodes=0
+
+[program:acwe]
+command=rq worker -u http://redis rq worker acwe
+autorestart=true
+exitcodes=0
+
+[program:cleanup]
+command=rq worker -u http://redis rq worker cleanup
+autorestart=true
+exitcodes=0
+
+[program:share_notification]
+command=rq worker -u http://redis rq worker share_notification
+autorestart=true
+exitcodes=0
+
+[program:stop_job]
+command=rq worker -u http://redis rq worker stop_job
+autorestart=true
+exitcodes=0
diff --git a/biomedisa/tests/test.sh b/biomedisa/tests/test.sh
new file mode 100755
index 0000000..cf16ce1
--- /dev/null
+++ b/biomedisa/tests/test.sh
@@ -0,0 +1,4 @@
+#! /bin/bash
+
+python -c 'import tensorflow; print(tensorflow.__version__)'
+python -c 'import keras; print(keras.__version__)'