Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Patch] Add loss for ORT inference #152

Merged
merged 15 commits into from
Apr 29, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test_onnxruntime_train.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ jobs:
- name: Build Image
working-directory: examples/onnxruntime/training/docker
run: |
docker build -f Dockerfile-cu10 -t ort/cu10 .
docker build -f Dockerfile-ort1.9.0-cu102 -t ort9/cu10 .
- name: Run Test
run: |
docker run --rm -p 80:8888 \
--gpus all \
-v $PWD:/workspace \
--workdir=/workspace \
ort/cu10:latest /bin/bash /run.sh
ort9/cu10:latest /bin/bash /run.sh

stop-runner:
name: Stop self-hosted EC2 runner
Expand Down
39 changes: 39 additions & 0 deletions examples/onnxruntime/training/docker/Dockerfile-ort1.11.1-cu113
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Use nvidia/cuda image
FROM nvidia/cuda:11.3.0-cudnn8-devel-ubuntu20.04
CMD nvidia-smi

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

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

RUN apt-get update && apt-get install -y --no-install-recommends apt-utils

# 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 && \
apt-get clean
RUN unattended-upgrade
RUN apt-get autoremove -y

# Install Pythyon (3.8 as default)
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
RUN apt-get install -y python3-pip
RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
RUN pip install --upgrade pip

# Install onnxruntime-training dependencies
# This version doesn't support running gpt2 with fp16
RUN pip install onnx==1.11.0 ninja
RUN pip install torch==1.11.0+cu113 -f https://download.pytorch.org/whl/torch_stable.html
RUN pip install onnxruntime-training==1.11.1+cu113 -f https://download.onnxruntime.ai/onnxruntime_stable_cu113.html
RUN pip install torch-ort
# RUN python -m torch_ort.configure
# RUN pip install coloredlogs seqeval scipy transformers datasets sacrebleu

WORKDIR .

CMD ["/bin/bash"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM nvidia/cuda:11.3.0-cudnn8-devel-ubuntu20.04
CMD nvidia-smi

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

# Bash shell
RUN chsh -s /bin/bash
Expand All @@ -26,15 +26,15 @@ RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
RUN pip install --upgrade pip

# Install onnxruntime-training dependencies
# Temporary workaround, wait for a more stable version on the next release of onnxruntime-training
# Temporary workaround, wait for a more stable version on the next release of onnxruntime-training
# (unable to run gpt2 with fp16 for now)
RUN pip install onnx==1.10.2 ninja
RUN pip install onnx==1.11.0 ninja
RUN pip install torch==1.11.0+cu113 -f https://download.pytorch.org/whl/torch_stable.html
RUN pip install onnxruntime-training==1.11.0+cu113 -f https://download.onnxruntime.ai/onnxruntime_stable_cu113.html
RUN pip install onnxruntime-training==1.12.0+cu113 -f https://download.onnxruntime.ai/onnxruntime_stable_cu113.html
RUN pip install torch-ort
# RUN python -m torch_ort.configure
# RUN pip install coloredlogs seqeval scipy transformers datasets sacrebleu

WORKDIR .

CMD ["/bin/bash"]
CMD ["/bin/bash"]
22 changes: 16 additions & 6 deletions examples/onnxruntime/training/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@ CMD=${1:-/bin/bash}
GPU_DEVICES=${2:-"all"}

# Build Image
# docker build -f Dockerfile-cu10 -t ort/cu10 .
# docker build -f Dockerfile-cu11 -t ort/cu11 .
# docker build -f Dockerfile-ort1.9.0-cu102 -t ort9/cu10 .
# docker build -f Dockerfile-ort1.9.0-cu111 -t ort9/cu11 .

# Run Image
# docker run -it --rm -p 80:8888 --gpus $GPU_DEVICES ort/cu10:latest $CMD
# docker run -it --rm -p 80:8888 --gpus $GPU_DEVICES ort/cu11:latest $CMD
# docker run -it --rm -p 80:8888 --gpus $GPU_DEVICES ort9/cu10:latest $CMD
# docker run -it --rm -p 80:8888 --gpus $GPU_DEVICES ort9/cu11:latest $CMD

# Install dependencies
pip install coloredlogs transformers>=4.15.0 datasets>=1.8.0
pip install scipy sklearn
pip install transformers>=4.15.0 datasets>=1.8.0
pip install coloredlogs absl-py rouge_score seqeval scipy sacrebleu transformers datasets nltk sklearn
pip install deepspeed mpi4py

# Install apex
git clone https://github.com/NVIDIA/apex \
&& cd apex \
&& pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./

# Install fairscale
pip install fairscale

python -m unittest tests/onnxruntime/nightly_test_onnxruntime.py
3 changes: 2 additions & 1 deletion optimum/onnx/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Mapping, Optional, Union

from transformers.file_utils import TensorType, is_tf_available, is_torch_available
from transformers.onnx.utils import compute_effective_axis_dimension
from transformers.utils import TensorType, is_tf_available, is_torch_available, logging
from transformers.utils import logging


if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion optimum/onnxruntime/quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def export(
The dictionary mapping the nodes name to their quantization ranges, used and required only when applying
static quantization.
use_external_data_format (`bool`, defaults to `False`):
Whether uto se external data format to store model which size is >= 2Gb.
Whether to use external data format to store model which size is >= 2Gb.
preprocessor (`QuantizationPreprocessor`, *optional*):
The preprocessor to use to collect the nodes to include or exclude from quantization.

Expand Down