Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
update alternative Dockerfiles for different CUDA versions (#170)
Browse files Browse the repository at this point in the history
* update alternative Dockerfiles for different CUDA versions

* update comment
  • Loading branch information
epwalsh committed Nov 18, 2020
1 parent 01bc777 commit 0789d72
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Changed

- Updated `Dockerfile.release` and `Dockerfile.commit` to work with different CUDA versions.


## [v1.2.2](https://github.com/allenai/allennlp-models/releases/tag/v1.2.2) - 2020-11-17

Expand Down
9 changes: 6 additions & 3 deletions Dockerfile.commit
@@ -1,10 +1,13 @@
# This Dockerfile is used to build an image from specific commits of allennlp and
# allennlp-models. It requires two build args: ALLENNLP_COMMIT and ALLENNLP_MODELS_COMMIT,
# which should be set to the desired commit SHAs for each repo, respectively.
# allennlp-models. It requires three build args: ALLENNLP_COMMIT, ALLENNLP_MODELS_COMMIT,
# and CUDA.
# ALLENNLP_COMMIT and ALLENNLP_MODELS_COMMIT should be set to the desired commit SHAs for each repo.
# CUDA should be set to a supported CUDA version such as '10.2' or '11.0'.

ARG ALLENNLP_COMMIT
ARG CUDA

FROM allennlp/commit:${ALLENNLP_COMMIT}
FROM allennlp/commit:${ALLENNLP_COMMIT}-cuda${CUDA}

ARG ALLENNLP_MODELS_COMMIT

Expand Down
16 changes: 9 additions & 7 deletions Dockerfile.release
@@ -1,13 +1,15 @@
# This Dockerfile is used to build an image from a specific PyPI release of allennlp and
# allennlp-models. It requires a single build arg, ALLENNLP_VERSION, which should
# be the PyPI release version (allennlp and allennlp-models are released together
# with the same version). For example, you could set ALLENNLP_VERSION=1.0.0rc3.
# allennlp-models.
# It requires two build args: RELEASE and CUDA.
# RELEASE should be a allennlp/allennlp-models version, such as '1.2.2',
# CUDA should be a supported CUDA version, such '10.2'.

ARG ALLENNLP_VERSION
ARG RELEASE
ARG CUDA

FROM allennlp/allennlp:v${ALLENNLP_VERSION}
FROM allennlp/allennlp:v${RELEASE}-cuda${CUDA}

# Need to specify this ARG again because the FROM stage consumes all args before it.
ARG ALLENNLP_VERSION
ARG RELEASE

RUN pip install --no-cache-dir allennlp-models==${ALLENNLP_VERSION}
RUN pip install --no-cache-dir allennlp-models==${RELEASE}
20 changes: 12 additions & 8 deletions README.md
Expand Up @@ -70,32 +70,36 @@ environment to a compute cluster.

Once you have [installed Docker](https://docs.docker.com/engine/installation/) you can either use a [prebuilt image from a release](https://hub.docker.com/r/allennlp/models) or build an image locally with any version of `allennlp` and `allennlp-models`.

If you have GPUs available, you also need to install the [nvidia-docker](https://github.com/NVIDIA/nvidia-docker) runtime.

To build an image locally from a specific release, run

```bash
docker build \
--build-arg ALLENNLP_VERSION=1.0.0rc3 \
--build-arg RELEASE=1.2.2 \
--build-arg CUDA=10.2 \
-t allennlp/models - < Dockerfile.release
```

Just replace "1.0.0rc3" with the desired version.
Just replace the `RELEASE` and `CUDA` build args what you need. Currently only CUDA 10.2 and 11.0 are officially supported.

Alternatively, you can build against specific commits of `allennlp` and `allennlp-models` with

```bash
docker build \
--build-arg ALLENNLP_COMMIT=e3d72fcb1664caf9554ef4e611191c33a7a5cbbd \
--build-arg ALLENNLP_MODELS_COMMIT=54a5df89da64d8d3869e746bc6dab940552dbfc4 \
--build-arg ALLENNLP_COMMIT=d823a2591e94912a6315e429d0fe0ee2efb4b3ee \
--build-arg ALLENNLP_MODELS_COMMIT=01bc777e0d89387f03037d398cd967390716daf1 \
--build-arg CUDA=10.2 \
-t allennlp/models - < Dockerfile.commit
```

Just change the `ALLENNLP_COMMIT` and `ALLENNLP_MODELS_COMMIT` build args to the desired commit SHAs.
Just change the `ALLENNLP_COMMIT` / `ALLENNLP_MODELS_COMMIT` and `CUDA` build args to the desired commit SHAs and CUDA versions, respectively.

Now run the following command to get an environment that will run on either the cpu or gpu.
Once you've built your image, you can run it like this:

```bash
mkdir -p $HOME/.allennlp/
docker run --rm -v $HOME/.allennlp:/root/.allennlp allennlp/models
docker run --rm --gpus all -v $HOME/.allennlp:/root/.allennlp allennlp/models
```

If you have GPUs available, you can install the [nvidia-docker](https://github.com/NVIDIA/nvidia-docker) runtime and then add the flag `--gpus all` right before `--rm`.
> Note: the `--gpus all` is only valid if you've installed the nvidia-docker runtime.

0 comments on commit 0789d72

Please sign in to comment.