Skip to content

Instantly share code, notes, and snippets.

@tueda
Last active March 29, 2023 12:31
Show Gist options
  • Save tueda/ac4a004de14b34e4e746e6412cf70249 to your computer and use it in GitHub Desktop.
Save tueda/ac4a004de14b34e4e746e6412cf70249 to your computer and use it in GitHub Desktop.
Docker image for MadGraph5_aMC@NLO + MadMiner + Jupyter. #docker #python #jupyter
*
!completion.jupyterlab-settings
!requirements.txt
!settings.jupyterlab-settings
!tracker.jupyterlab-settings
{
"continuousHinting": true
}
FROM rootproject/root:6.28.00-ubuntu22.04
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential=12.* \
ca-certificates=* \
curl=7.* \
gfortran=4:11.* \
git=1:2.* \
less=590-* \
libboost-all-dev=1.* \
python3-pip=22.* \
rsync=3.* \
wget=1.* \
&& rm -rf /var/lib/apt/lists/*
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV PROJECT_FOLDER "/madminer"
ENV SOFTWARE_FOLDER "/madminer/software"
ENV MG_VERSION "MG5_aMC_v3.4.2"
ENV MG_FOLDER "MG5_aMC_v3_4_2"
ENV MG_FOLDER_PATH "${SOFTWARE_FOLDER}/${MG_FOLDER}"
ENV MG_BINARY_PATH "${SOFTWARE_FOLDER}/${MG_FOLDER}/bin/mg5_aMC"
ENV PATH $PATH:$ROOTSYS/bin
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:$ROOTSYS/lib
RUN python3 -m pip install --no-cache-dir --upgrade pip==23.0.1 && \
python3 -m pip install --no-cache-dir six==1.16.0
RUN mkdir -p ${SOFTWARE_FOLDER} && \
curl -sSL "https://launchpad.net/mg5amcnlo/3.0/3.4.x/+download/${MG_VERSION}.tar.gz" \
| tar -xz -C ${SOFTWARE_FOLDER}
RUN echo "n" | python3 ${MG_BINARY_PATH}
RUN echo "install pythia8" | python3 ${MG_BINARY_PATH}
RUN echo "install Delphes" | python3 ${MG_BINARY_PATH}
RUN echo "set auto_convert_model T" | python3 ${MG_BINARY_PATH}
RUN echo "import model EWdim6-full" | python3 ${MG_BINARY_PATH}
ENV ROOT_INCLUDE_PATH "${ROOT_INCLUDE_PATH}:${MG_FOLDER_PATH}/Delphes/external"
ARG torch_whl=cpu
RUN python3 -m pip install --no-cache-dir torch==2.0.0 --index-url https://download.pytorch.org/whl/${torch_whl}
# RUN python3 -m pip install --no-cache-dir install \
# 'python-lsp-server[all]==1.7.1' \
# black==23.3.0 \
# isort==5.12.0 \
# jupyter-client==7.4.9 \
# jupyterlab-code-formatter==1.6.0 \
# jupyterlab-lsp==4.0.1 \
# jupyterlab==3.6.2 \
# lckr-jupyterlab-variableinspector==3.0.9 \
# madminer==0.9.6 \
# matplotlib==3.7.1 \
# notebook==6.5.3 \
# && python3 -m pip freeze | grep -v '^six\|^torch' >/tmp/requirements.txt
COPY requirements.txt /tmp/
RUN python3 -m pip install --no-cache-dir -r /tmp/requirements.txt \
&& rm /tmp/requirements.txt
RUN jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
# hadolint ignore=DL3059
RUN useradd -m user
USER user
ENV HOME=/home/user
ENV SHELL=/bin/bash
WORKDIR $HOME
RUN mkdir -p $HOME/.jupyter/lab/user-settings/@jupyterlab/notebook-extension/
COPY --chown=user:user tracker.jupyterlab-settings $HOME/.jupyter/lab/user-settings/@jupyterlab/notebook-extension/
RUN ln -s / .lsp_symlink && \
mkdir -p $HOME/.jupyter/jupyter/ && \
echo 'c.ContentsManager.allow_hidden = True' >>$HOME/.jupyter/jupyter_lab_config.py && \
mkdir -p $HOME/.jupyter/lab/user-settings/@jupyter-lsp/jupyterlab-lsp/
COPY --chown=user:user completion.jupyterlab-settings $HOME/.jupyter/lab/user-settings/@jupyter-lsp/jupyterlab-lsp/
RUN mkdir -p $HOME/.jupyter/lab/user-settings/@ryantam626/jupyterlab_code_formatter/
COPY --chown=user:user settings.jupyterlab-settings $HOME/.jupyter/lab/user-settings/@ryantam626/jupyterlab_code_formatter/
CMD ["/bin/bash"]
aiofiles==22.1.0
aiosqlite==0.18.0
anyio==3.6.2
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
arrow==1.2.3
astroid==2.15.1
asttokens==2.2.1
attrs==22.2.0
autopep8==1.6.0
awkward0==0.15.5
Babel==2.12.1
backcall==0.2.0
beautifulsoup4==4.12.0
black==23.3.0
bleach==6.0.0
cachetools==5.3.0
certifi==2022.12.7
cffi==1.15.1
charset-normalizer==3.1.0
click==8.1.3
cmake==3.25.0
comm==0.1.3
contourpy==1.0.7
cycler==0.11.0
debugpy==1.6.6
decorator==5.1.1
defusedxml==0.7.1
Deprecated==1.2.13
dill==0.3.6
docstring-to-markdown==0.12
entrypoints==0.4
executing==1.2.0
fastjsonschema==2.16.3
filelock==3.9.0
flake8==6.0.0
fonttools==4.39.3
fqdn==1.5.1
h5py==3.8.0
hepunits==2.3.1
idna==3.4
install==1.3.5
ipykernel==6.22.0
ipython==8.11.0
ipython-genutils==0.2.0
isoduration==20.11.0
isort==5.12.0
jedi==0.18.2
Jinja2==3.1.2
json5==0.9.11
jsonpointer==2.3
jsonschema==4.17.3
jupyter-events==0.6.3
jupyter-lsp==2.0.1
jupyter-ydoc==0.2.3
jupyter_client==7.4.9
jupyter_core==5.3.0
jupyter_server==2.5.0
jupyter_server_fileid==0.8.0
jupyter_server_terminals==0.4.4
jupyter_server_ydoc==0.8.0
jupyterlab==3.6.2
jupyterlab-code-formatter==1.6.0
jupyterlab-lsp==4.0.1
jupyterlab-pygments==0.2.2
jupyterlab_server==2.21.0
kiwisolver==1.4.4
lazy-object-proxy==1.9.0
lckr-jupyterlab-variableinspector==3.0.9
lit==15.0.7
madminer==0.9.6
MarkupSafe==2.1.2
matplotlib==3.7.1
matplotlib-inline==0.1.6
mccabe==0.7.0
mistune==2.0.5
mpmath==1.2.1
mypy-extensions==1.0.0
nbclassic==0.5.3
nbclient==0.7.2
nbconvert==7.2.10
nbformat==5.8.0
nest-asyncio==1.5.6
networkx==3.0
notebook==6.5.3
notebook_shim==0.2.2
numpy==1.21.5
packaging==23.0
pandocfilters==1.5.0
parso==0.8.3
particle==0.22.0
pathspec==0.11.1
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.4.0
platformdirs==3.2.0
pluggy==1.0.0
prometheus-client==0.16.0
prompt-toolkit==3.0.38
psutil==5.9.4
ptyprocess==0.7.0
pure-eval==0.2.2
pycodestyle==2.10.0
pycparser==2.21
pydocstyle==6.2.3
pyflakes==3.0.1
Pygments==2.14.0
pylint==2.17.1
pyparsing==3.0.9
pyrsistent==0.19.3
python-dateutil==2.8.2
python-json-logger==2.0.7
python-lsp-jsonrpc==1.0.0
python-lsp-server==1.7.1
pytoolconfig==1.2.5
PyYAML==6.0
pyzmq==25.0.2
requests==2.28.2
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rope==1.7.0
scipy==1.10.1
Send2Trash==1.8.0
sniffio==1.3.0
snowballstemmer==2.2.0
soupsieve==2.4
stack-data==0.6.2
sympy==1.11.1
terminado==0.17.1
tinycss2==1.2.1
toml==0.10.2
tomli==2.0.1
tomlkit==0.11.7
tornado==6.2
traitlets==5.9.0
triton==2.0.0
typing_extensions==4.4.0
ujson==5.7.0
uproot3==3.14.4
uproot3-methods==0.10.1
uri-template==1.2.0
urllib3==1.26.15
vector==1.0.0
wcwidth==0.2.6
webcolors==1.13
webencodings==0.5.1
websocket-client==1.5.1
whatthepatch==1.0.4
wrapt==1.15.0
y-py==0.5.9
yapf==0.32.0
ypy-websocket==0.8.2
#!/bin/bash
set -eu
set -o pipefail
work_dir=$(pwd)
cd "$(dirname "$0")"
torch_whl=cpu
if command -v nvidia-smi &>/dev/null; then
torch_whl=cu118
fi
docker build . -t my-madminer-jupyter-env --build-arg torch_whl=$torch_whl
cmd=
extra_opts=
if [[ $torch_whl != cpu ]]; then
extra_opts="$extra_opts --gpus all"
fi
if [ $# -ge 1 ]; then
case $1 in
bash)
;;
root)
cmd="root -b"
;;
notebook|lab)
for port in $(seq 8888 9999); do
if ! echo -ne "\035" | telnet 127.0.0.1 "$port" >/dev/null 2>&1; then
break
fi
done
cmd="jupyter $1 --no-browser --ip 0.0.0.0 --port $port"
extra_opts="$extra_opts -p $port:$port"
;;
*)
echo "unknown command $1" >&2
exit 1
;;
esac
fi
# shellcheck disable=SC2086
docker run -it --rm \
-v "$work_dir:/home/user/shared" \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/group:/etc/group:ro \
-u "$(id -u "$USER"):$(id -g "$USER")" \
$extra_opts \
my-madminer-jupyter-env \
$cmd
{
"formatOnSave": true,
"cacheFormatters": true
}
{
"codeCellConfig": {
"autoClosingBrackets": true,
"lineNumbers": true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment