Skip to content

Commit

Permalink
Add ORT trainer docs and dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
mht-sharma committed Nov 21, 2023
1 parent 65df71b commit b2641a5
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/source/onnxruntime/usage_guides/trainer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ To use `ORTTrainer` or `ORTSeq2SeqTrainer`, you need to install ONNX Runtime Tra
To set up the environment, we __strongly recommend__ you install the dependencies with Docker to ensure that the versions are correct and well
configured. You can find dockerfiles with various combinations [here](https://github.com/huggingface/optimum/tree/main/examples/onnxruntime/training/docker).

#### Setup for NVIDIA GPU

Here below we take the installation of `onnxruntime-training 1.14.0` as an example:

* If you want to install `onnxruntime-training 1.14.0` via [Dockerfile](https://github.com/huggingface/optimum/blob/main/examples/onnxruntime/training/docker/Dockerfile-ort1.14.0-cu116):
Expand All @@ -80,6 +82,32 @@ And run post-installation configuration:
python -m torch_ort.configure
```

#### Setup for AMD GPU

Here below we take the installation of `onnxruntime-training` nightly as an example:

* If you want to install `onnxruntime-training` via [Dockerfile](https://github.com/huggingface/optimum/blob/main/examples/onnxruntime/training/docker/Dockerfile-ort-nightly-rocm57):

```bash
docker build -f Dockerfile-ort-nightly-rocm57 -t ort/train:nightly .
```

* If you want to install the dependencies beyond in a local Python environment. You can pip install them once you have [ROCM 5.7](https://rocmdocs.amd.com/en/latest/deploy/linux/quick_start.html) well installed.

```bash
pip install onnx ninja
pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm5.7
pip install pip install --pre onnxruntime-training -f https://download.onnxruntime.ai/onnxruntime_nightly_rocm57.html
pip install torch-ort
pip install --upgrade protobuf==3.20.2
```

And run post-installation configuration:

```bash
python -m torch_ort.configure
```

### Install Optimum

You can install Optimum via pypi:
Expand Down
43 changes: 43 additions & 0 deletions examples/onnxruntime/training/docker/Dockerfile-ort-nightly-rocm57
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Use rocm image
FROM rocm/pytorch:rocm5.7_ubuntu22.04_py3.10_pytorch_2.0.1
CMD rocm-smi

# Ignore interactive questions during `docker build`
ENV DEBIAN_FRONTEND noninteractive

# Versions
# available options 3.10
ARG PYTHON_VERSION=3.10

# Bash shell
RUN chsh -s /bin/bash
SHELL ["/bin/bash", "-c"]

# Install and update tools to minimize security vulnerabilities
RUN apt-get update
RUN apt-get install -y software-properties-common wget apt-utils patchelf git libprotobuf-dev protobuf-compiler cmake \
bzip2 ca-certificates libglib2.0-0 libxext6 libsm6 libxrender1 mercurial subversion libopenmpi-dev ffmpeg && \
apt-get clean
RUN apt-get autoremove -y

ARG PYTHON_EXE=/opt/conda/envs/py_$PYTHON_VERSION/bin/python

# (Optional) Intall test dependencies
RUN $PYTHON_EXE -m pip install -U pip
RUN $PYTHON_EXE -m pip install git+https://github.com/huggingface/transformers
RUN $PYTHON_EXE -m pip install datasets accelerate evaluate coloredlogs absl-py rouge_score seqeval scipy sacrebleu nltk scikit-learn parameterized sentencepiece
RUN $PYTHON_EXE -m pip install deepspeed
RUN conda install -y mpi4py

# PyTorch
RUN $PYTHON_EXE -m pip install onnx ninja

# ORT Module
RUN $PYTHON_EXE -m pip install --pre onnxruntime-training -f https://download.onnxruntime.ai/onnxruntime_nightly_rocm57.html
RUN $PYTHON_EXE -m pip install torch-ort
RUN $PYTHON_EXE -m pip install --upgrade protobuf==3.20.2
RUN $PYTHON_EXE -m torch_ort.configure

WORKDIR .

CMD ["/bin/bash"]

0 comments on commit b2641a5

Please sign in to comment.