Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions Dockerfile.arm
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
FROM --platform=linux/arm64 python:3.10-slim
# This applies to mchip on arm64
FROM python:3.10-slim

RUN apt-get update && apt-get install -y \
build-essential \
git \
curl \
ca-certificates \
libxrender1 \
libxext6 \
libsm6 \
&& rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir uv

WORKDIR /app

COPY pyproject.toml .
COPY VERSION .
COPY pyproject.toml VERSION README.md LICENSE build.sh install.sh ./
COPY uv.lock.mchip ./uv.lock
COPY atomsci ./atomsci

RUN uv sync --extra mchip --group docker --no-dev
RUN uv sync --frozen --extra mchip --group docker --group dev
ENV PATH="/app/.venv/bin:$PATH"

CMD ["uv", "run", "python", "-c", "import atomsci; print('arm64/mchip-style ok')"]
# Install atomsci-ampl
RUN ./build.sh
RUN ./install.sh

CMD ["uv", "run", "python", "-c", "import atomsci.ddm; print('arm64/mchip-style ok')"]
26 changes: 21 additions & 5 deletions Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
FROM python:3.10-slim

RUN pip install uv
RUN apt-get update && apt-get install -y \
build-essential \
git \
curl \
ca-certificates \
libxrender1 \
libxext6 \
libsm6 \
&& rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir uv

WORKDIR /app

COPY pyproject.toml .
COPY pyproject.toml VERSION README.md LICENSE build.sh install.sh ./
COPY uv.lock.cpu ./uv.lock
COPY atomsci ./atomsci
COPY VERSION .

RUN uv sync --extra cpu
RUN uv sync --frozen --extra cpu --group docker --group dev
ENV PATH="/app/.venv/bin:$PATH"

# Install atomsci-ampl
RUN ./build.sh
RUN ./install.sh

CMD ["uv", "run", "python", "-c", "import atomsci; print('cpu ok')"]
CMD ["uv", "run", "python", "-c", "import atomsci.ddm; print('cpu ok')"]
30 changes: 24 additions & 6 deletions Dockerfile.gpu
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04

RUN apt-get update && apt-get install -y python3.10 python3-pip
RUN python3.10 -m pip install uv
RUN apt-get update && apt-get install -y \
python3.10 \
python3-pip \
python3.10-venv \
build-essential \
git \
curl \
ca-certificates \
libxrender1 \
libxext6 \
libsm6 \
&& rm -rf /var/lib/apt/lists/*

RUN python3.10 -m pip install --no-cache-dir uv

WORKDIR /app
COPY pyproject.toml .

COPY pyproject.toml VERSION README.md LICENSE build.sh install.sh ./
COPY uv.lock.cuda ./uv.lock
COPY atomsci ./atomsci
COPY VERSION .

RUN uv sync --extra cuda
RUN uv sync --frozen --extra cuda --group docker --group dev
ENV PATH="/app/.venv/bin:$PATH"

# Install atomsci-ampl
RUN ./build.sh
RUN ./install.sh

CMD ["uv", "run", "python3.10", "-c", "import atomsci; print('cuda ok')"]
CMD ["uv", "run", "python", "-c", "import atomsci.ddm; print('cuda ok')"]
19 changes: 14 additions & 5 deletions Dockerfile.rocm
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@ RUN apt-get update && apt-get install -y \
build-essential \
git \
curl \
ca-certificates
ca-certificates \
libxrender1 \
libxext6 \
libsm6 \
&& rm -rf /var/lib/apt/lists/*

RUN python3.10 -m pip install --no-cache-dir uv

WORKDIR /app

COPY pyproject.toml .
COPY VERSION .
COPY pyproject.toml VERSION README.md LICENSE build.sh install.sh ./
COPY uv.lock.rocm ./uv.lock
COPY atomsci ./atomsci

RUN uv sync --extra rocm --group docker --no-dev
RUN uv sync --frozen --extra rocm --group docker --group dev
ENV PATH="/app/.venv/bin:$PATH"

CMD ["uv", "run", "python3.10", "-c", "import atomsci; print('rocm ok')"]
# Install atomsci-ampl
RUN ./build.sh
RUN ./install.sh

CMD ["uv", "run", "python", "-c", "import atomsci.ddm; print('rocm ok')"]
23 changes: 19 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ VERSION=$(shell cat VERSION)
ifeq ($(ENV), prod)
TAG = v$(VERSION)-$(SUBTAG)
else
TAG = $(ENV)-$(PLATFORM)
TAG = $(ENV)-$(SUBTAG)
endif

# IMAGE REPOSITORY
Expand Down Expand Up @@ -58,9 +58,24 @@ load-docker:
pull-docker:
docker pull $(IMAGE_REPO):$(TAG)

# Push Docker image
# Push Docker image.
# if cpu, also set those as default tags. like atomsci/atomsci-ampl:vx.x.x, atomsci/atomsci-ampl:latest
push-docker:
docker buildx build --no-cache -t $(IMAGE_REPO):$(TAG) -t $(IMAGE_REPO):latest-$(SUBTAG) --build-arg ENV=$(ENV) $(PLATFORM_ARG) --push -f Dockerfile.$(PLATFORM) .
ifeq ($(PLATFORM),cpu)
docker buildx build --no-cache \
-t $(IMAGE_REPO):$(TAG) \
-t $(IMAGE_REPO):v$(VERSION) \
-t $(IMAGE_REPO):latest \
-t $(IMAGE_REPO):latest-$(SUBTAG) \
--build-arg ENV=$(ENV) $(PLATFORM_ARG) --push \
-f Dockerfile.$(PLATFORM) .
else
docker buildx build --no-cache \
-t $(IMAGE_REPO):$(TAG) \
-t $(IMAGE_REPO):latest-$(SUBTAG) \
--build-arg ENV=$(ENV) $(PLATFORM_ARG) --push \
-f Dockerfile.$(PLATFORM) .
endif

# Save Docker image
save-docker:
Expand Down Expand Up @@ -182,4 +197,4 @@ sync-rocm:
./sync_uv_env.sh rocm

sync-mchip:
./sync_uv_env.sh mchip
./sync_uv_env.sh mchip
18 changes: 18 additions & 0 deletions Makefile.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ This Makefile is designed to manage Jupyter environments, Docker images, and the
- `make save-docker`: Save the Docker image to a tarball (`ampl-$(PLATFORM)-$(ENV).tar.gz`).
- `make build-docker`: Build the Docker image for the specified platform and environment.

***Note:***

Usage for docker build:

```
make build-docker PLATFORM=<variant> ARCH=<docker-platform> ENV=<env>
```

Examples:

```
make build-docker PLATFORM=cpu ARCH=linux/amd64 ENV=prod
make build-docker PLATFORM=gpu ARCH=linux/amd64 ENV=prod
make build-docker PLATFORM=rocm ARCH=linux/amd64 ENV=prod
make build-docker PLATFORM=rocm ARCH=linux/amd64 ENV=prod
make build-docker PLATFORM=cpu ARCH=linux/arm64 ENV=prod
```

- **Jupyter Notebook and Lab:**

- `make jupyter-notebook`: Start a Jupyter Notebook server.
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ python -m ipykernel install --user --name atomsci-env
- Create a workspace folder to mount with Docker environment and transfer files.
- Get the Docker image and run it. Since 1.6.3, there are some changes with the AMPL Docker.

The AMPL Docker image is available on Docker Hub:

[https://hub.docker.com/r/atomsci/atomsci-ampl](https://hub.docker.com/r/atomsci/atomsci-ampl)

To retrieve, run version 1.6.2 or earlier, please specify the desired version tag:
```
docker pull atomsci/atomsci-ampl:v1.6.2
Expand Down
24 changes: 12 additions & 12 deletions atomsci/ddm/docs/source/get_started/install_with_docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This page provides an option to use Docker to install `AMPL <https://github.com/

To install `AMPL <https://github.com/ATOMScience-org/AMPL>`_ software using Docker, the major steps are:

* :ref:`Create Docker`
* :ref:`Create or download a Docker`
* :ref:`Start container`
* :ref:`Start Jupyter notebook`

Expand All @@ -29,7 +29,7 @@ You can either pull a prebuilt `AMPL <https://github.com/ATOMScience-org/AMPL>`_
Option 1: Pull a Prebuilt AMPL Image from Docker Repo
=====================================================

The simplest method is to download a prebuilt Docker image from DockerHub. For every official `AMPL <https://github.com/ATOMScience-org/AMPL>`_ release, a docker image will be pushed to its `Docker Hub <https://hub.docker.com/r/atomsci/atomsci-ampl>`_.
The simplest method is to download a prebuilt Docker image from DockerHub. For every official `AMPL <https://github.com/ATOMScience-org/AMPL>`_ release, a docker image will be pushed to its `Docker Hub <https://hub.docker.com/r/atomsci/atomsci-ampl>`_.

To pull a prebuilt `AMPL <https://github.com/ATOMScience-org/AMPL>`_ image, the method varies based on its version.

Expand All @@ -39,11 +39,11 @@ For a pre-1.6.3 release:

docker pull atomsci/atomsci-ampl:v1.6.2 # Specify a version to pull, ie, v1.6.2.

For 1.6.3 and later, you can download the latest images for various platforms (CPU, GPU, or Linux/ARM64), an example:
For 1.6.3 and later, you can download the latest images for various platforms (CPU, GPU, or Linux/ARM64), an example:

.. code-block::

docker pull atomsci/atomsci-ampl:latest-cpu # Specify the latest image built for a platform (use those for tags 'cpu', 'gpu', or 'arm')
docker pull atomsci/atomsci-ampl:latest-cpu # Specify the latest image built for a platform (use those for tags 'cpu', 'gpu', or 'arm')

After that, please follow the instruction from the ":ref:`Start container`" step.

Expand All @@ -60,7 +60,7 @@ First clone `AMPL <https://github.com/ATOMScience-org/AMPL>`_ github repo, then

.. code-block::

git clone https://github.com/ATOMScience-org/AMPL.git
git clone https://github.com/ATOMScience-org/AMPL.git
### The following line is _optional_. If you want to check out a development branch instead of the default branch (master).
git checkout 1.6.3 # (optional) checkout a dev branch, 1.6.3 for example
cd AMPL
Expand All @@ -82,7 +82,7 @@ This normally takes about 15-20 minutes to build. Once it's built on your machin
Run a Docker Container
**********************

To see what images are running on your machine, type "docker images".
To see what images are running on your machine, type "docker images".


.. image:: ../_static/img/install_with_docker_files/docker_run.png
Expand All @@ -93,13 +93,13 @@ Use "docker run ... `<IMAGE>`" command to start the container. The command synta

docker run -it -p <port>:<port> -v <local_folder>:<directory_in_docker> <IMAGE> bash

Use the following example to start the container. For images created or downloaded from version 1.6.3 or later, append 'bash' to the end of the docker run command to open a bash session. By default, the container starts with a Python interpreter session.
Use the following example to start the container. For images created or downloaded from version 1.6.3 or later, append 'bash' to the end of the docker run command to open a bash session. By default, the container starts with a Python interpreter session.

.. code-block::

docker run -it -p 8888:8888 -v ${PWD}:/home atomsci/atomsci-ampl:latest-cpu bash # replace with your <IMAGE>:<TAG>

To get more info for the "docker run" command options, type "docker run --help":
To get more info for the "docker run" command options, type "docker run --help":

.. code-block::

Expand Down Expand Up @@ -135,10 +135,10 @@ Copy and paste the URL from the output message (highlighted in yellow from above
.. note::

*If this doesn't work, exit the container and choose a different port
such as "7777" or "8899" (in all 3 places it's
written), then rerun both commands in "Start a Docker container" and
"Start the Jupyter notebook from a container".
Be sure to save any work in your container. See instructions on how to "Save work from Docker Jupyter".*
such as "7777" or "8899" (in all 3 places it's
written), then rerun both commands in "Start a Docker container" and
"Start the Jupyter notebook from a container".
Be sure to save any work in your container. See instructions on how to "Save work from Docker Jupyter".*

Once connected, you will see a screen like this:

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ pattern = "(?P<version>\\d+\\.\\d+\\.\\d+.*)"
[tool.hatch.build.targets.wheel]
packages = ["atomsci"]
exclude = [
"uv.lock*",
"atomsci/ddm/examples/archive/**", # old tutorials
"atomsci/ddm/test/test_datasets/**", # test datasets
"**/*.tar.gz",
Expand All @@ -126,6 +127,7 @@ exclude = [

[tool.hatch.build.targets.sdist]
exclude = [
"uv.lock*",
"atomsci/ddm/examples/archive/**", # old tutorials
"atomsci/ddm/test/test_datasets/**", # test datasets
"**/*.tar.gz",
Expand Down
Loading