Skip to content

Upgrade to onnx 1.9 #847

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

Merged
merged 40 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
33e6ef5
jetson 1.8
chayim Jun 14, 2021
b101e59
1.8 in the Makefile
chayim Jun 15, 2021
be2a69d
starting single use
chayim Jun 15, 2021
ddb2111
splitting a backend
chayim Jun 15, 2021
68fdfc7
onnx 1.8 64-bit linux, 64-bit linux with gpu, and jetson
chayim Jun 15, 2021
1136450
split up onnx to use docker library parts
chayim Jun 16, 2021
fffa1ea
pr comments
chayim Jun 17, 2021
bbfde5b
pr comments
chayim Jun 17, 2021
af40e81
Merge remote-tracking branch 'origin/master' into ck-onnx-1.8
chayim Jun 20, 2021
8743a75
merge Chayim PR for building onnx
alonre24 Oct 5, 2021
1444119
WIP
alonre24 Oct 5, 2021
c8e49a9
Merge branch 'master' into upgrade_to_onnx_1.9
alonre24 Oct 5, 2021
c56aa85
remove temporarily the custom allocator support
alonre24 Oct 5, 2021
bab06d3
Merge branch 'upgrade_to_onnx_1.9' of https://github.com/RedisAI/Redi…
alonre24 Oct 5, 2021
d1c5e80
xenial onnx 1.9 build using the template
chayim Oct 5, 2021
08e8ef9
fixing python
chayim Oct 5, 2021
63a318d
build onnx + test building with DISABLE_EXTERNAL_INITIALIZERS flag
alonre24 Oct 6, 2021
724319b
Add the model with the external initializer
alonre24 Oct 6, 2021
c9b82a3
Variablizing CUDA support
chayim Oct 6, 2021
1aa4836
use new key for deps cache
alonre24 Oct 6, 2021
f312541
Merge branch 'upgrade_to_onnx_1.9' of https://github.com/RedisAI/Redi…
alonre24 Oct 6, 2021
2977098
gcc due to glibc versioning
chayim Oct 7, 2021
728b6b9
s/bionic/buster/ is back
chayim Oct 7, 2021
2b1f0bd
update deps cache key to v1.2.5
alonre24 Oct 7, 2021
8b4e718
Merge branch 'upgrade_to_onnx_1.9' of https://github.com/RedisAI/Redi…
alonre24 Oct 7, 2021
24f7ea9
PR comments
chayim Oct 10, 2021
063b86a
PR fixes - documentation
alonre24 Oct 10, 2021
1b3ac61
Merge branch 'upgrade_to_onnx_1.9' of https://github.com/RedisAI/Redi…
alonre24 Oct 10, 2021
74bf607
venv docs update
chayim Oct 10, 2021
3e54ea2
get caller position when assertion fails in an auxiliary file
alonre24 Oct 10, 2021
7d31242
Return filename instead of function name
alonre24 Oct 10, 2021
c45934a
More PR fixes
alonre24 Oct 10, 2021
af1bcf8
merge add tests utility
alonre24 Oct 10, 2021
de4c368
Merge branch 'upgrade_to_onnx_1.9' of https://github.com/RedisAI/Redi…
alonre24 Oct 10, 2021
8958a0d
Merge branch 'master' into upgrade_to_onnx_1.9
alonre24 Oct 11, 2021
55022ef
Build onnx with DISABLE_EXTERNAL_INITIALIZERS flag for GPU as well
alonre24 Oct 11, 2021
b18ecec
Merge branch 'master' into upgrade_to_onnx_1.9
alonre24 Oct 11, 2021
696747c
Merge branch 'upgrade_to_onnx_1.9' of https://github.com/RedisAI/Redi…
alonre24 Oct 11, 2021
f63f95f
update deps cache key in CI after rebuilding and publishing for gpu
alonre24 Oct 11, 2021
ab20006
ignore overlap valgrind errors from onnx lib
alonre24 Oct 11, 2021
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
18 changes: 9 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ commands:
- checkout-all
- restore_cache:
keys:
- v1-dependencies-{{ checksum "get_deps.sh" }}-cpu
- v1.2.5-deps-{{ checksum "get_deps.sh" }}-cpu
# If no exact match is found will get dependencies from source
- setup-build-system
- run:
Expand All @@ -112,7 +112,7 @@ commands:
- save_cache:
paths:
- deps
key: v1-dependencies-{{ checksum "get_deps.sh" }}-cpu
key: v1.2.5-deps-{{ checksum "get_deps.sh" }}-cpu
- run:
name: Build
command: make -C opt all SHOW=1
Expand Down Expand Up @@ -151,7 +151,7 @@ commands:
- checkout-all
- restore_cache:
keys:
- v1-dependencies-{{ checksum "get_deps.sh" }}-cpu
- v1.2.5-deps-{{ checksum "get_deps.sh" }}-cpu
# If no exact match is found will get dependencies from source
- setup-build-system
- run:
Expand All @@ -178,7 +178,7 @@ commands:
- checkout-all
- restore_cache:
keys:
- v1-dependencies-{{ checksum "get_deps.sh" }}-gpu
- v1.2.5-deps-{{ checksum "get_deps.sh" }}-gpu
- relocate-docker-storage
- run:
name: Build
Expand All @@ -189,7 +189,7 @@ commands:
- save_cache:
paths:
- deps
key: v1-dependencies-{{ checksum "get_deps.sh" }}-gpu
key: v1.2.5-deps-{{ checksum "get_deps.sh" }}-gpu
- run:
name: Test
command: |
Expand Down Expand Up @@ -239,7 +239,7 @@ jobs:
- checkout-all
- restore_cache:
keys:
- v1-dependencies-{{ checksum "get_deps.sh" }}-<<parameters.osnick>>-<<parameters.target>>
- v1.2.5-deps-{{ checksum "get_deps.sh" }}-<<parameters.osnick>>-<<parameters.target>>
- setup-automation

# since we run in parallel, we need to generate docker files with different suffixes hence the DOCKER_SUFFIX
Expand All @@ -260,7 +260,7 @@ jobs:
- save_cache:
paths:
- deps
key: v1-dependencies-{{ checksum "get_deps.sh" }}-<<parameters.osnick>>-<<parameters.target>>
key: v1.2.5-deps-{{ checksum "get_deps.sh" }}-<<parameters.osnick>>-<<parameters.target>>
- persist_to_workspace:
root: bin/
paths:
Expand All @@ -275,7 +275,7 @@ jobs:
- checkout-all
- restore_cache:
keys:
- v1-dependencies-{{ checksum "get_deps.sh" }}-cpu
- v1.2.5-deps-{{ checksum "get_deps.sh" }}-cpu
# If no exact match is found will get dependencies from source
- setup-build-system
- run:
Expand Down Expand Up @@ -309,7 +309,7 @@ jobs:
- checkout-all
- restore_cache:
keys:
- v1-dependencies-{{ checksum "get_deps.sh" }}-cpu
- v1.2.5-deps-{{ checksum "get_deps.sh" }}-cpu
# If no exact match is found will get dependencies from source
- setup-build-system
- run:
Expand Down
47 changes: 47 additions & 0 deletions docs/developer-backends.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# RedisAI Development Backends

This document describes how a backend for RedisAI can be built, from this repository. It highlights the supported compilation devices on a per-backend basis, and highlights the tools and commands required. Unless indicated otherwise, a backend is compiled in a docker, which is responsible for the configuration and installation of all tools required for a given backend on a per-platform basis.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why "a backend"?
we build only ONNXRuntime
maybe explain the need for building a backend. First, start with explaining that we use DISABLE_EXTERNAL_INITIALIZERS=ON and that made go and building the backend from the source. Also, explain that we do not build the other backend libraries but downloading their binaries from the library websites.

When we need to add more "backend builds" we can add additional "how-to"s

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I understand. I that OK if I will make the rephrasing in the next PR (#806 - the one that updates Torch and TF)?


To follow these instructions, this repository must be cloned with all of its submodules (i.e *git clone --recursive https://github.com/redisai/redisai*)

GNU Make is used as a runner for the dockerfile generator. Python is the language used for the generator script, and jinja is the templating library used to create the docker file from a template *dockerfile.tmpl* that can be found in the directory of a given backend listed below.

## Tools

Building the backends requires installation of the following tools:

1. gnu make
1. python (3.0 or higher)
1. docker
1. jinja2

On ubuntu bionic these can be installed by running the following steps, to install python3, create a virtual environment, and install the jinja templating dependency. Replace */path/to/venv* with your desired virtualenv location.

```
sudo apt install python3 python3-dev make docker
python3 -m venv /path/to/venv
source /path/to/venv/bin/activate
pip install jinja
```

-------

## Backends

### onnxruntime

We build Onnxruntime library with DISABLE_EXTERNAL_INITIALIZERS=ON build flag. This means that loading ONNX models that use external files to store the initial (usually very large) values of the model's operations, is invalid. That is, initializers values must be part of the serialized model, which is also the standard use case.

**Compilation target devices:**

1. x86\_64 bit linux systems

1. x86\_64 bit linux systems with a GPU

**Directory:** opt/build/onnxruntime

**Build options:**

1. To build run *make*

1. To build with GPU support on x86\_64 run *make GPU=1*
2 changes: 2 additions & 0 deletions docs/developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ sudo ./opt/system-setup.py

To compile RedisAI, run *make -C opt all*, from the root of the repository.

Build the backends is described in [this document](developer-backends.md).

### Testing

**Running Tests**
Expand Down
2 changes: 1 addition & 1 deletion get_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ fi

################################################################################### ONNXRUNTIME

ORT_VERSION="1.7.1"
ORT_VERSION="1.9.0"

if [[ $WITH_ORT != 0 ]]; then
[[ $FORCE == 1 ]] && rm -rf $ONNXRUNTIME
Expand Down
65 changes: 65 additions & 0 deletions opt/build/backends.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# PRODUCT var is the backend name, without any other configuration (set in each backend's corresponding makefile)

# default is x64
ARCH=$(shell ${READIES}/bin/platform --arch)
OS=$(shell ${READIES}/bin/platform --os)
REDIS_CMAKE_ARCH=x86_64
DOCKER_ORG=redislabs

# jetson
ifeq ($(shell test -e /usr/share/doc/nvidia-l4t-jetson-io && echo -n yes),yes)
ARCH=jetson
REDIS_CMAKE_ARCH=aarch64
GPU=1
endif
export REDIS_CMAKE_ARCH

# override if necessary in top-level make files
DEFAULT_DOCKER_TAG=${DOCKER_ORG}/${PRODUCT}:build
CIDFILE=${PRODUCT}.${ARCH}.cid

ifeq ($(GPU),1)
REDIS_GPU=1
VARIANT=gpu
CIDFILE=${PRODUCT}.${ARCH}.gpu.cid # this way we can build from the same tree across platforms
export REDIS_GPU
endif

ifeq ($(VARIANT),)
BACKEND_NAME=${PRODUCT}-${OS}-${ARCH}-${VERSION}.tgz
else
BACKEND_NAME=${PRODUCT}-${OS}-${ARCH}-${VARIANT}-${VERSION}.tgz
endif

S3_URL=redismodules/${PRODUCT}

build:
@rm -f ${BACKEND_NAME} *.cid
REDIS_ARCH=${ARCH} \
REDIS_OSNICK=${OSNICK} \
${READIES}/bin/dockerwrapper \
-d ${CURDIR}/Dockerfile${DOCKER_SUFFIX} \
-t ${DEFAULT_DOCKER_TAG} \
-S ../dockerparts \
-e REDIS \
-D "${DOCKER_OPTS}" \
${DOCKER_ARGS}
docker create --cidfile ${CIDFILE} ${DEFAULT_DOCKER_TAG}
docker cp `cat ${CIDFILE}`:/build/${BACKEND_NAME} .

publish:
@aws s3 cp ${BACKEND_NAME} s3://$(S3_URL)/ --acl public-read

# ---------------------------------------------------------------------------------------------------
define HELP
make build> # build the backend, tagging the docker image so that the files can be copied out of it
OSNICK=<> # optional base operating system (xenial, bionic, etc)
REDIS_CUDA_VERSION=<> # optional cuda version to override
DOCKER_SUFFIX=<> # optional suffix for the generated dockerfile
GPU=1 # if set, build the GPU
make publish > # upload the generated artifacts to s3 same
GPU=1 # if set, upload the GPU artifact (defaults to cpu)
endef
# ---------------------------------------------------------------------------------------------------
include ${READIES}/mk/help.defs
include ${READIES}/mk/help.rules
26 changes: 26 additions & 0 deletions opt/build/dockerparts/apt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
RUN apt-get update -qq
RUN DEBIAN_NONINTERACTIVE=y1 apt-get install -y software-properties-common

{% if REDIS_OSNICK == 'xenial' %}
RUN add-apt-repository ppa:deadsnakes/ppa
RUN add-apt-repository ppa:ubuntu-toolchain-r/test
{% endif %}

RUN apt-get update -qq
RUN DEBIAN_NONINTERACTIVE=1 apt-get install -y curl wget tar git patch \
build-essential libcurl4-openssl-dev libssl-dev libatlas-base-dev zlib1g-dev \
python3.7 python3-pip python3-dev python3-numpy \
gcc-7 g++-7

RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 60
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7

RUN python3 -m pip install --upgrade pip setuptools wheel

ENV LANG=en_US.UTF-8
RUN apt-get install -y locales && \
sed -i -e "s/# $LANG.*/$LANG UTF-8/" /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=$LANG


9 changes: 9 additions & 0 deletions opt/build/dockerparts/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% set cmake_version = "3.19.7" %}
RUN wget -q https://github.com/Kitware/CMake/releases/download/v{{cmake_version}}/cmake-{{cmake_version}}-Linux-{{REDIS_CMAKE_ARCH}}.tar.gz -O /tmp/cmake.tgz

WORKDIR /tmp
RUN tar -zxpf /tmp/cmake.tgz
RUN mv /tmp/cmake*/bin/* /usr/bin
RUN mv /tmp/cmake-*/share/cmake* /usr/share/


2 changes: 2 additions & 0 deletions opt/build/onnxruntime/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Dockerfile
onnxruntime.x64.cid
53 changes: 0 additions & 53 deletions opt/build/onnxruntime/Dockerfile.arm

This file was deleted.

47 changes: 0 additions & 47 deletions opt/build/onnxruntime/Dockerfile.arm7

This file was deleted.

Loading