-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from elephant-track/dev
ELEPHANT server v0.5.3
- Loading branch information
Showing
13 changed files
with
160 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM pytorch/pytorch:1.10.0-cuda11.3-cudnn8-runtime | ||
FROM nvidia/cuda:11.3.1-runtime-ubuntu20.04 | ||
# Modified from https://github.com/tiangolo/uwsgi-nginx-flask-docker (Apache license) | ||
|
||
LABEL maintainer="Ko Sugawara <[email protected]>" | ||
|
@@ -13,19 +13,30 @@ RUN set -x \ | |
ca-certificates \ | ||
curl \ | ||
gnupg \ | ||
gosu && \ | ||
gosu \ | ||
gettext-base && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ENV PATH /opt/conda/bin:$PATH | ||
SHELL ["/bin/bash", "-c"] | ||
|
||
# Install Python modules | ||
COPY ./environment.yml /tmp/environment.yml | ||
RUN sed -i '/.\/elephant-core/d' /tmp/environment.yml \ | ||
&& conda install -c conda-forge -y mamba \ | ||
&& curl -OL https://repo.continuum.io/miniconda/Miniconda3-py37_4.11.0-Linux-x86_64.sh \ | ||
&& bash Miniconda3-py37_4.11.0-Linux-x86_64.sh -bfp /opt/conda \ | ||
&& rm Miniconda3-py37_4.11.0-Linux-x86_64.sh \ | ||
&& . /opt/conda/etc/profile.d/conda.sh \ | ||
&& conda init \ | ||
&& echo "conda activate base" >> ~/.bashrc \ | ||
&& conda install -c conda-forge -y mamba=0.19.1 \ | ||
&& mamba clean -qafy \ | ||
&& mamba env update -f /tmp/environment.yml \ | ||
&& mamba clean -qafy \ | ||
&& rm -rf /tmp/elephant-core \ | ||
&& rm /tmp/environment.yml | ||
RUN mamba install jupyter | ||
|
||
# Install and set up RabbbitMQ | ||
COPY docker/install-rabbitmq.sh /tmp/install-rabbitmq.sh | ||
|
@@ -38,16 +49,15 @@ COPY docker/rabbitmq.sh /rabbitmq.sh | |
RUN chmod +x /rabbitmq.sh | ||
|
||
# Set up nginx | ||
COPY docker/nginx.conf /etc/nginx/nginx.conf | ||
COPY docker/nginx.conf.template /etc/nginx/nginx.conf.template | ||
EXPOSE 80 443 | ||
RUN groupadd -r nginx && useradd -r -g nginx nginx | ||
# forward request and error logs to docker log collector | ||
RUN ln -sf /dev/stdout /var/log/nginx/access.log \ | ||
&& ln -sf /dev/stderr /var/log/nginx/error.log | ||
|
||
RUN pip install memory_profiler line_profiler | ||
RUN mamba install jupyter | ||
RUN pip install --no-deps stardist==0.8.3 csbdeep==0.7.2 numba==0.56.0 llvmlite==0.39.0 natsort==8.1.0 | ||
# RUN pip install memory_profiler line_profiler | ||
# RUN pip install --no-deps stardist==0.8.3 csbdeep==0.7.2 numba==0.56.0 llvmlite==0.39.0 natsort==8.1.0 | ||
|
||
# Copy the base uWSGI ini file to enable default dynamic uwsgi process number | ||
COPY docker/uwsgi.ini /etc/uwsgi/uwsgi.ini | ||
|
@@ -77,7 +87,6 @@ ENTRYPOINT ["/entrypoint.sh"] | |
COPY ./elephant-core /tmp/elephant-core | ||
RUN pip install -U /tmp/elephant-core && rm -rf /tmp/elephant-core | ||
|
||
|
||
# Run the start script provided by the parent image tiangolo/uwsgi-nginx. | ||
# It will check for an /app/prestart.sh script (e.g. for migrations) | ||
# And then will start Supervisor, which in turn will start Nginx and uWSGI | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM elephant-server:0.5.2 | ||
FROM elephant-server:0.5.3 | ||
|
||
LABEL maintainer="Ko Sugawara <[email protected]>" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
/etc/init.d/rabbitmq-server start | ||
rabbitmqctl add_user $RABBITMQ_USER $RABBITMQ_PASSWORD 2>/dev/null | ||
rabbitmqctl set_user_tags $RABBITMQ_USER administrator | ||
rabbitmqctl set_permissions -p / $RABBITMQ_USER ".*" ".*" ".*" | ||
/etc/init.d/rabbitmq-server stop | ||
echo "*** User '$RABBITMQ_USER' with password '$RABBITMQ_PASSWORD' completed. ***" | ||
echo "*** RabbitMQ server is working at $RABBITMQ_NODENAME:$RABBITMQ_NODE_PORT ***" | ||
echo "*** Log in the WebUI at port $RABBITMQ_MANAGEMENT_PORT (example: http://localhost:$RABBITMQ_MANAGEMENT_PORT) ***" | ||
|
||
# enable rabbitmq_management | ||
rabbitmq-plugins enable rabbitmq_management | ||
|
||
echo "management.tcp.port = $RABBITMQ_MANAGEMENT_PORT" > /etc/rabbitmq/rabbitmq.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Bootstrap: docker | ||
From: pytorch/pytorch:1.10.0-cuda11.3-cudnn8-runtime | ||
From: nvidia/cuda:11.3.1-runtime-ubuntu20.04 | ||
|
||
%files | ||
./docker /docker | ||
|
@@ -15,8 +15,14 @@ From: pytorch/pytorch:1.10.0-cuda11.3-cudnn8-runtime | |
export PYTHONPATH=/app | ||
export MKL_THREADING_LAYER=GNU | ||
export GRPC_POLL_STRATEGY=epoll1 | ||
export PATH=/opt/conda/bin:$PATH | ||
export RABBITMQ_USER=user | ||
export RABBITMQ_PASSWORD=user | ||
export RABBITMQ_MANAGEMENT_PORT=15672 | ||
export RABBITMQ_PID_FILE=/var/lib/rabbitmq/mnesia/rabbitmq.pid | ||
export ElEPHANT_HTTP_PORT=8080 | ||
|
||
%post | ||
%post -c /bin/bash | ||
# Install requirements | ||
set -x \ | ||
&& apt-get update \ | ||
|
@@ -26,33 +32,43 @@ From: pytorch/pytorch:1.10.0-cuda11.3-cudnn8-runtime | |
supervisor \ | ||
ca-certificates \ | ||
curl \ | ||
gnupg && \ | ||
gnupg \ | ||
gosu \ | ||
gettext-base && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Install Python modules | ||
sed -i 's/.\/elephant-core/\/src\/elephant-core/g' /src/environment.yml \ | ||
&& conda install -c conda-forge -y mamba \ | ||
&& curl -OL https://repo.continuum.io/miniconda/Miniconda3-py37_4.11.0-Linux-x86_64.sh \ | ||
&& bash Miniconda3-py37_4.11.0-Linux-x86_64.sh -bfp /opt/conda \ | ||
&& rm Miniconda3-py37_4.11.0-Linux-x86_64.sh \ | ||
&& . /opt/conda/etc/profile.d/conda.sh \ | ||
&& conda init \ | ||
&& echo "conda activate base" >> ~/.bashrc \ | ||
&& conda install -c conda-forge -y mamba==0.19.1 \ | ||
&& mamba clean -qafy \ | ||
&& mamba env update -f /src/environment.yml \ | ||
&& mamba clean -qafy \ | ||
&& rm -rf /src/elephant-core \ | ||
&& rm /src/environment.yml | ||
|
||
# Install and set up RabbbitMQ | ||
chmod +x /docker/install-rabbitmq.sh && /docker/install-rabbitmq.sh | ||
echo "rabbitmq-server \$@" > /rabbitmq.sh | ||
chmod +x /rabbitmq.sh | ||
cp /docker/rabbitmq-env.conf /etc/rabbitmq/rabbitmq-env.conf | ||
export RABBITMQ_USER=user | ||
export RABBITMQ_PASSWORD=user | ||
export RABBITMQ_MANAGEMENT_PORT=15672 | ||
cp /docker/setup-rabbitmq.sh /setup-rabbitmq.sh | ||
chmod +x /setup-rabbitmq.sh | ||
|
||
RABBITMQ_USER=user && RABBITMQ_PASSWORD=user | ||
/etc/init.d/rabbitmq-server start | ||
rabbitmqctl add_user $RABBITMQ_USER $RABBITMQ_PASSWORD 2>/dev/null | ||
rabbitmqctl set_user_tags $RABBITMQ_USER administrator | ||
rabbitmqctl set_permissions -p / $RABBITMQ_USER ".*" ".*" ".*" | ||
/etc/init.d/rabbitmq-server stop | ||
/setup-rabbitmq.sh | ||
|
||
# Set up nginx | ||
cp /docker/nginx.conf /etc/nginx/nginx.conf | ||
groupadd nginx && useradd -g nginx nginx | ||
sed -i 's/listen 80/listen 8080/g' /etc/nginx/nginx.conf | ||
cp /docker/nginx.conf.template /etc/nginx/nginx.conf.template | ||
groupadd -r nginx && useradd -r -g nginx nginx | ||
|
||
# forward request and error logs to docker log collector | ||
ln -sf /dev/stdout /var/log/nginx/access.log && \ | ||
|
@@ -64,7 +80,6 @@ From: pytorch/pytorch:1.10.0-cuda11.3-cudnn8-runtime | |
|
||
# Custom Supervisord config | ||
cp /docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf | ||
sed -i 's#/usr/bin/pidproxy /var/lib/rabbitmq/mnesia/rabbitmq.pid /bin/bash -c "/rabbitmq.sh"#rabbitmq-server#g' /etc/supervisor/conf.d/supervisord.conf | ||
sed -i '/user=user/d' /etc/supervisor/conf.d/supervisord.conf | ||
sed -i '/group=user/d' /etc/supervisor/conf.d/supervisord.conf | ||
|
||
|
@@ -84,6 +99,8 @@ From: pytorch/pytorch:1.10.0-cuda11.3-cudnn8-runtime | |
mkdir -p $HOME/.elephant_binds/etc | ||
cp -a /etc/nginx $HOME/.elephant_binds/etc/ | ||
cp -a /etc/rabbitmq $HOME/.elephant_binds/etc/ | ||
chown -R $(id -u):$(id -g) $HOME/.elephant_binds | ||
|
||
|
||
%labels | ||
Author Ko Sugawara <[email protected]> | ||
|
@@ -92,7 +109,7 @@ From: pytorch/pytorch:1.10.0-cuda11.3-cudnn8-runtime | |
This is a container to run ELEPHANt server. | ||
Usage: | ||
apptainer build --fakeroot elephant.sif elephant.def | ||
apptainer run --bind $HOME elephant.sif | ||
apptainer run --fakeroot --bind $HOME:/root elephant.sif | ||
apptainer instance start --nv --bind $HOME,$HOME/.elephant_binds/var/lib:/var/lib,$HOME/.elephant_binds/var/log:/var/log,$HOME/.elephant_binds/var/run:/var/run,$HOME/.elephant_binds/etc/nginx:/etc/nginx,$HOME/.elephant_binds/etc/rabbitmq:/etc/rabbitmq,$ELEPHANT_WORKSPACE:/workspace elephant.sif elephant | ||
apptainer exec instance://elephant python /opt/elephant/script/dataset_generator.py --uint16 /workspace/datasets/elephant-demo/elephant-demo.h5 /workspace/datasets/elephant-demo | ||
SINGULARITYENV_CUDA_VISIBLE_DEVICES=0 apptainer exec instance://elephant /start.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.