From cb7aab785edc8aafd94b721d2e13548925e5989f Mon Sep 17 00:00:00 2001 From: Fabian Zills <46721498+PythonFZ@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:31:23 +0200 Subject: [PATCH] update docker image (#288) * update docker image * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update docker permission issues description * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * jupyter support --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- Dockerfile | 19 +++++++++---------- README.md | 21 ++++++++++++++++++++- entrypoint.sh | 23 ----------------------- 3 files changed, 29 insertions(+), 34 deletions(-) delete mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 78a598d7..a19dfff6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,16 @@ -FROM pytorch/pytorch:2.1.2-cuda11.8-cudnn8-runtime -RUN conda install git +FROM python:3.11 +RUN apt update && apt install -y git -COPY . /workspace/ipsuite +# RUN python3 -m pip config set global.break-system-packages true +COPY . /workspace/ipsuite WORKDIR /workspace/ipsuite -RUN pip install .[comparison,gap,nequip,apax,allegro,mace] -RUN pip install --upgrade torch --extra-index-url https://download.pytorch.org/whl/cu116 -RUN pip install --upgrade "jax[cuda11_pip]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html + +RUN pip install .[comparison,gap,apax,mace] +RUN pip install --upgrade torch torchvision torchaudio +RUN pip install --upgrade "jax[cuda12_pip]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html RUN pip install git+https://github.com/PythonFZ/torch-dftd.git@patch-2 RUN pip install dvc-s3 - -COPY entrypoint.sh entrypoint.sh -RUN chmod +x entrypoint.sh +RUN pip install --no-cache-dir notebook jupyterlab WORKDIR /app -ENTRYPOINT ["/workspace/ipsuite/entrypoint.sh"] diff --git a/README.md b/README.md index 91b3a85c..84ffbb2c 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,31 @@ Examples can be found at: # Docker Image -You can use IPSuite directly from within docker by calling it e.g. like: +We provide an IPSuite docker image for Linux that includes the `apax`, `mace` +and `gap` MLPs. You can use IPSuite directly from within the image by calling: ```sh docker run -it -v "$(pwd):/app" --gpus all pythonf/ipsuite dvc repro docker run -it -v "$(pwd):/app" --gpus all pythonf/ipsuite python docker run -it -v "$(pwd):/app" --gpus all pythonf/ipsuite zntrack list +docker run -it -v "$(pwd):/app" --gpus all --rm -p 8888:8888 pythonf/ipsuite jupyter lab --ip=0.0.0.0 --port=8888 --allow-root +``` + +## Fix Permission Issues + +Running `dvc repro` via the docker container will create files owned by +`root:root`. If you solely use docker this will not cause any issues. If you +switch between docker and a `dvc` version on your host system, you might +encounter permission errors. You can resolve them, by changing the ownership of +the files. You can do this via the host `chown "$(id -u):$(id -g)" -R .` or from +inside the docker container: + +```sh +echo $(id -u):$(id -g) +docker run -it -v "$(pwd):/app" pythonf/ipsuite /bin/bash +addgroup --gid $GROUP_ID user +adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user +chown user:user -R . ``` # References diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100644 index 7d9a532c..00000000 --- a/entrypoint.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# Check the command passed to the container -case "$1" in - python) - # If "python" is passed, open a Python shell - exec python - ;; - dvc) - # If "dvc" is passed, run "dvc repro" with the rest of the arguments - shift - exec dvc "$@" - ;; - zntrack) - # If "zntrack" is passed, run "zntrack" with the rest of the arguments - shift - exec zntrack "$@" - ;; - *) - # Default: run the command as is - exec "$@" - ;; -esac