Skip to content

Commit

Permalink
Add docker section in readme, install optional reqs in Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
francoishernandez committed Dec 4, 2023
1 parent de25119 commit 117be02
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,30 @@ If you used previous versions of OpenNMT-py, you can check the [Changelog](https

## Setup

### Using docker

To facilitate setup and reproducibility, some docker images are made available via the Github Container Registry:
https://github.com/OpenNMT/OpenNMT-py/pkgs/container/opennmt-py

You can adapt the workflow and build your own image(s) depending on specific needs by using `build.sh` and `Dockerfile` in the `docker` directory of the repo.

```
docker pull ghcr.io/opennmt/opennmt-py:3.4.3-ubuntu22.04-cuda12.1
```

Example oneliner to run a container and open a bash shell within it
```
docker run --rm -it --runtime=nvidia ghcr.io/opennmt/opennmt-py:test-ubuntu22.04-cuda12.1
```
Note: you need to have the [Nvidia Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) (formerly nvidia-docker) installed to properly take advantage of the CUDA/GPU features.

Depending on your needs you can add various flags:
- `-p 5000:5000` to forward some exposed port from your container to your host;
- `-v /some/local/directory:/some/container/directory` to mount some local directory to some container directory;
- `--entrypoint some_command` to directly run some specific command as the container entry point (instead of the default bash shell);

### Installing locally

OpenNMT-py requires:

- Python >= 3.8
Expand All @@ -78,7 +102,7 @@ Note: if you encounter a `MemoryError` during installation, try to use `pip` wit
pip install -r requirements.opt.txt
```

## Manual installation of some dependencies
### Manual installation of some dependencies

Apex is highly recommended to have fast performance (especially the legacy fusedadam optimizer and FusedRMSNorm)

Expand Down
13 changes: 13 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,21 @@ RUN pip3 install -v --no-build-isolation \
--global-option="--fast_multihead_attn" \
./

# Install flash-attention
RUN pip install flash-attn --no-build-isolation

# Install llm-awq
RUN git clone https://github.com/mit-han-lab/llm-awq && \
cd llm-awq && \
pip install -e . && \
cd ..

# Install AutoAWQ
RUN pip install autoawq

COPY . /opennmt-py
WORKDIR /opennmt-py
RUN pip install -r requirements.opt.txt
RUN pip install -e .

WORKDIR /
Expand Down
1 change: 1 addition & 0 deletions requirements.opt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ scipy
bitsandbytes>=0.41.2
safetensors
spacy
gradio

0 comments on commit 117be02

Please sign in to comment.