onnxruntime/dockerfiles
Du Li 095d55bf54
Cherry picking for Rel-1.6 (#6006)
* Update onnx (#5720)

* update onnx

* update docker image for testing
(cherry picked from commit 705d093167)

* cherry pick PR 5720

* C#: Add CreateFromMemory to FixedBufferOnnxValue to allow bind user buffers and pass custom binary compatible types (#5886)

Add CreateFromMemory to FixedBufferOnnxValue so users can bind their own custom binary compatible buffers to feed/fetch data.
(cherry picked from commit c2d610066a)

* [Java] Initial Apple Silicon support (#5891)

* Rearranging checks in onnxruntime_mlas.cmake to pickup Apple Silicon.

On an M1 Macbook Pro clang reports:

$ clang -dumpmachine
arm64-apple-darwin20.1.0

So the regex check needs to look for "arm64" first, as otherwise it
matches 32-bit ARM and you get NEON compilation failures.

* Adding Java side library loading support for Apple Silicon (and other aarch64 architectures).

* Adding Qgemm fix from @tracysh

* Fixes the java packaging on Windows.

* Missed a check in the java platform detector.
(cherry picked from commit 8b83c51a35)

* Add OpenVINO EP shared lib to Py Wheel (#5920)

* Add OpenVINO EP shared lib to Py Wheel

Include the libonnxruntime_providers_openvino.so/.dll to the wheel

* Follow libs.extend pattern as other EPs
(cherry picked from commit 40926867c3)

* Make NNAPI EP reject nodes with no-shape inputs (#5927)

(cherry picked from commit 87368655e2)

* Sahar/fix documentation shared lib (#5926)

* Update OpenVINO-ExecutionProvider.Md

update openvino-executionprovider.md for shared library

* Update Build.md

updated --build_shared_lib flag for building openvino shared provider lib

* Update Dockerfile.openvino

building for shared library with the new changes for openvino shared lib

* Revert "Update Build.md"

This reverts commit c9cf5fee76be7fdc10cadf07259f1d4ed5b45b93.

* Revert "Update Dockerfile.openvino "

This reverts commit e1624e4f93a4cfb425b6f21d7fb71b299a146740.

* Update OpenVINO-ExecutionProvider.md

fix documentation to the shared library

Co-authored-by: sfatimar <sahar.fatima@intel/com>
(cherry picked from commit 8168c91978)

* Update dockerfiles (#5929)

1. Remove conda from the images. Because conda contains a file named /opt/miniconda/lib/libcrypto.so.1.0.0 which can't pass our security scan. Also, it will be easier for us to manage the third party usage registrations.
2. Remove openssh from the images. Because the official openssh package provided by Ubuntu can't pass our security scan.
3. Reduce the image size to 1/3 by using stages. Also, because it contains less packages, it will be less often needed to update.
4. Put the LICENSE-IMAGE.txt file in right place. It is missed in current images. You can see it was added to a temp folder "/code" but it got deleted afterwards.
5. Update the CPU docker image's base image to Ubuntu 18.04. The GPU one is already 18.04. It's better to keep them the same.
6. Remove the build arg ONNXRUNTIME_REPO/ONNXRUNTIME_BRANCH. Instead, the new one always uses the local source. I feel it can reduce confusion.
(cherry picked from commit 1dbabb2362)

* Add Longformer Attention Cuda Op(#5932)

Limitation: Global tokens must be at the beginning of sequence.
(cherry picked from commit 31a6be3d67)

* Bug fix for MaskRCNN and FasterRCNN (#5935)

Signed-off-by: MaajidKhan <n.maajidkhan@gmail.com>
(cherry picked from commit e39e82b43a)

* Fix publishing pipelines. (#5942)

Fix publishing pipelines.
(cherry picked from commit c4b55d29fe)

* Fix Python Linux GPU package name (#5943)

Fix Python Linux GPU package name. I accidentally added "noopenmp" to it.

(cherry picked from commit 5fdd9f0fd2)

* Update BUILD.md with shared provider information (#5944)

* Update build instructions to include information about shared providers

(cherry picked from commit 27513d1fd7)

* [OpenVINO]Fix memory leak in `IsDebugEnabled()` under Windows (#5948)

* w

* w

Co-authored-by: modav <modav@microsoft.com>
(cherry picked from commit e207589631)

* Add support for Python 3.8+ on Windows when CUDA is enabled (#5956)

(cherry picked from commit 015fbb3dbb)

* Support the cross compiling for Apple Silicon (#5974)

* support macos_arm64 cross compiling

* update the build docs

* update as commented.

* Update BUILD.md
(cherry picked from commit 2ec211ea7b)

* Update docker files to put 'unattended-upgrades' in a right place(#5983)

(cherry picked from commit 3323fb6082)

* Enable the xcode build for Apple Silicon (arm64 MacOS) (#5924)

* fix the build script for macos/xcode

* add the version check

* correct the osx-arch configuration

* typo
(cherry picked from commit 1852ade75d)

* Add python 3.9 support (#5874)

1. Add python 3.9 support(except Linux ARM)
2. Add Windows GPU python 3.8 to our packaging pipeline.

* Revert some pipeline changes in #5874

Co-authored-by: Ashwini Khade <askhade@microsoft.com>
Co-authored-by: Du Li <duli@OrtTrainingDev0.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
Co-authored-by: Dmitri Smirnov <yuslepukhin@users.noreply.github.com>
Co-authored-by: Adam Pocock <craigacp@gmail.com>
Co-authored-by: S. Manohar Karlapalem <manohar.karlapalem@intel.com>
Co-authored-by: Guoyu Wang <62914304+gwang-msft@users.noreply.github.com>
Co-authored-by: sfatimar <64512376+sfatimar@users.noreply.github.com>
Co-authored-by: Changming Sun <chasun@microsoft.com>
Co-authored-by: Tianlei Wu <tlwu@microsoft.com>
Co-authored-by: Maajid khan <n.maajidkhan@gmail.com>
Co-authored-by: Ryan Hill <38674843+RyanUnderhill@users.noreply.github.com>
Co-authored-by: Moshe David <mosdav165@gmail.com>
Co-authored-by: Ivan Stojiljkovic <17503404+ivanst0@users.noreply.github.com>
Co-authored-by: Wenbing Li <10278425+wenbingl@users.noreply.github.com>
2020-12-02 13:45:20 -08:00
..
scripts [Vitis-AI EP] Fix to enable multi-output subgraphs inside Vitis-AI EP + edit docs (#4171) 2020-06-13 04:56:07 -07:00
Dockerfile.arm32v7 Various armv7 related fixes (#5394) 2020-10-09 22:34:32 +10:00
Dockerfile.cuda Cherry picking for Rel-1.6 (#6006) 2020-12-02 13:45:20 -08:00
Dockerfile.jetson add install sec updates (#4957) 2020-08-31 18:13:02 -07:00
Dockerfile.migraphx Amdmigraphx update to rocm3.7 (#5362) 2020-10-05 15:34:24 -07:00
Dockerfile.nuphar Fix nuphar docker file build break 2020-10-26 20:08:07 -07:00
Dockerfile.openvino [OPENVINO-EP] 2021.1 Release (#5431) 2020-10-14 15:56:00 -07:00
Dockerfile.openvino-csharp [OpenVINO-EP] Add Dockerfile with C# API bindings (#5633) 2020-10-30 11:27:15 -07:00
Dockerfile.server
Dockerfile.source Cherry picking for Rel-1.6 (#6006) 2020-12-02 13:45:20 -08:00
Dockerfile.tensorrt unattended-upgrades (#4804) 2020-08-14 18:12:27 -07:00
Dockerfile.training pin transformers dependence to sentencepiece==0.1.92 due to ci fail (#5607) 2020-10-27 16:21:40 -07:00
Dockerfile.vitisai Add use_openmp back to the docker files 2020-05-25 14:17:48 -07:00
LICENSE-IMAGE.txt
README.md Cherry picking for Rel-1.6 (#6006) 2020-12-02 13:45:20 -08:00

Docker Containers for ONNX Runtime

Dockerfiles

Published Microsoft Container Registry (MCR) Images

Use docker pull with any of the images and tags below to pull an image and try for yourself. Note that the CPU and CUDA images include additional dependencies like miniconda for compatibility with AzureML image deployment.

Example: Run docker pull mcr.microsoft.com/azureml/onnxruntime:latest-cuda to pull the latest released docker image with ONNX Runtime GPU, CUDA, and CUDNN support.

Build Flavor Base Image ONNX Runtime Docker Image tags Latest
Source (CPU) mcr.microsoft.com/azureml/onnxruntime :v0.4.0, :v0.5.0, v0.5.1, :v1.0.0, :v1.2.0, :v1.3.0, :v1.4.0, :v1.5.2 :latest
CUDA (GPU) mcr.microsoft.com/azureml/onnxruntime :v0.4.0-cuda10.0-cudnn7, :v0.5.0-cuda10.1-cudnn7, :v0.5.1-cuda10.1-cudnn7, :v1.0.0-cuda10.1-cudnn7, :v1.2.0-cuda10.1-cudnn7, :v1.3.0-cuda10.1-cudnn7, :v1.4.0-cuda10.1-cudnn7, :v1.5.2-cuda10.2-cudnn8 :latest-cuda
OpenVino (VAD-M) mcr.microsoft.com/azureml/onnxruntime :v0.5.0-openvino-r1.1-vadm, :v1.0.0-openvino-r1.1-vadm, :v1.4.0-openvino-2020.3.194-vadm, :v1.5.2-openvino-2020.4.287-vadm :latest-openvino-vadm
OpenVino (MYRIAD) mcr.microsoft.com/azureml/onnxruntime :v0.5.0-openvino-r1.1-myriad, :v1.0.0-openvino-r1.1-myriad, :v1.3.0-openvino-2020.2.120-myriad, :v1.4.0-openvino-2020.3.194-myriad, :v1.5.2-openvino-2020.4.287-myriad :latest-openvino-myriad
OpenVino (CPU) mcr.microsoft.com/azureml/onnxruntime :v1.0.0-openvino-r1.1-cpu, :v1.3.0-openvino-2020.2.120-cpu, :v1.4.0-openvino-2020.3.194-cpu, :v1.5.2-openvino-2020.4.287-cpu :latest-openvino-cpu
OpenVINO (GPU) mcr.microsoft.com/azureml/onnxruntime :v1.3.0-openvino-2020.2.120-gpu, :v1.4.0-openvino-2020.3.194-gpu, :v1.5.2-openvino-2020.4.287-gpu :latest-openvino-gpu
Nuphar mcr.microsoft.com/azureml/onnxruntime :latest-nuphar
Server mcr.microsoft.com/onnxruntime/server :v0.4.0, :v0.5.0, :v0.5.1, :v1.0.0 :latest
MIGraphX (GPU) mcr.microsoft.com/azureml/onnxruntime :v0.6 :latest
Training (usage) mcr.microsoft.com/azureml/onnxruntime-training :0.1-rc1-openmpi4.0-cuda10.1-cudnn7.6-nccl2.4.8, :0.1-rc2-openmpi4.0-cuda10.2-cudnn7.6-nccl2.7.6, :0.1-rc3.1-openmpi4.0-cuda10.2-cudnn8.0-nccl2.7 :latest

Building and using Docker images

CPU

Ubuntu 16.04, CPU, Python Bindings

  1. Build the docker image from the Dockerfile in this repository.
docker build -t onnxruntime-source -f Dockerfile.source ..
  1. Run the Docker image
docker run -it onnxruntime-source

CUDA

Ubuntu 18.04, CUDA 10.2, CuDNN 8

  1. Build the docker image from the Dockerfile in this repository.
docker build -t onnxruntime-cuda -f Dockerfile.cuda ..
  1. Run the Docker image
docker run --gpus all -it onnxruntime-cuda
or
nvidia-docker run -it onnxruntime-cuda

TensorRT

Ubuntu 18.04, CUDA 11.0, TensorRT 7.1.3.4

  1. Build the docker image from the Dockerfile in this repository.
docker build -t onnxruntime-trt -f Dockerfile.tensorrt .
  1. Run the Docker image
docker run -it onnxruntime-trt

OpenVINO

Public Preview

Ubuntu 18.04, Python & C# Bindings

  1. Build the onnxruntime image for one of the accelerators supported below.

    Retrieve your docker image in one of the following ways.

    • Choose Dockerfile.openvino for Python API or Dockerfile.openvino-csharp for C# API as for building an OpenVINO 2021.1 based Docker image. Providing the docker build argument DEVICE enables the onnxruntime build for that particular device. You can also provide arguments ONNXRUNTIME_REPO and ONNXRUNTIME_BRANCH to test that particular repo and branch. Default repository is http://github.com/microsoft/onnxruntime and default branch is master.
      docker build --rm -t onnxruntime --build-arg DEVICE=$DEVICE -f <Dockerfile> .
      
    • Pull the official image from DockerHub.
  2. DEVICE: Specifies the hardware target for building OpenVINO Execution Provider. Below are the options for different Intel target devices.

Device Option Target Device
CPU_FP32 Intel CPUs
GPU_FP32 Intel Integrated Graphics
GPU_FP16 Intel Integrated Graphics
MYRIAD_FP16 Intel MovidiusTM USB sticks
VAD-M_FP16 Intel Vision Accelerator Design based on MovidiusTM MyriadX VPUs
HETERO:<DEVICE_TYPE_1>,<DEVICE_TYPE_2>,<DEVICE_TYPE_3>... All Intel® silicons mentioned above
MULTI:<DEVICE_TYPE_1>,<DEVICE_TYPE_2>,<DEVICE_TYPE_3>... All Intel® silicons mentioned above

Specifying Hardware Target for HETERO or Multi-Device Build:

HETERO:<DEVICE_TYPE_1>,<DEVICE_TYPE_2>.. MULTI:<DEVICE_TYPE_1>,<DEVICE_TYPE_2>.. The <DEVICE_TYPE> can be any of these devices from this list ['CPU','GPU','MYRIAD','FPGA','HDDL']

A minimum of two DEVICE_TYPE'S should be specified for a valid HETERO or Multi-Device Build.

Example: HETERO:MYRIAD,CPU HETERO:HDDL,GPU,CPU MULTI:MYRIAD,GPU,CPU

This is the hardware accelerator target that is enabled by default in the container image. After building the container image for one default target, the application may explicitly choose a different target at run time with the same container by using the Dynamic device selction API.

OpenVINO on CPU

  1. Build the docker image from the DockerFile in this repository.

    docker build --rm -t onnxruntime-cpu --build-arg DEVICE=CPU_FP32 --network host -f <Dockerfile> .
    
  2. Run the docker image

     docker run -it onnxruntime-cpu
    

OpenVINO on GPU

  1. Build the docker image from the DockerFile in this repository.
     docker build --rm -t onnxruntime-gpu --build-arg DEVICE=GPU_FP32 --network host -f <Dockerfile> .
    
  2. Run the docker image
    docker run -it --device /dev/dri:/dev/dri onnxruntime-gpu:latest
    

OpenVINO on Myriad VPU Accelerator

  1. Build the docker image from the DockerFile in this repository.

     docker build --rm -t onnxruntime-myriad --build-arg DEVICE=MYRIAD_FP16 --network host -f <Dockerfile> .
    
  2. Install the Myriad rules drivers on the host machine according to the reference in here

  3. Run the docker image by mounting the device drivers

    docker run -it --network host --privileged -v /dev:/dev  onnxruntime-myriad:latest
    
    

OpenVINO on VAD-M Accelerator Version

  1. Download OpenVINO Full package for version 2021.1 for Linux on host machine from this link and install it with the help of instructions from this link

  2. Install the drivers on the host machine according to the reference in here

  3. Build the docker image from the DockerFile in this repository.

     docker build --rm -t onnxruntime-vadm --build-arg DEVICE=VAD-M_FP16 --network host -f <Dockerfile> .
    
  4. Run hddldaemon on the host in a separate terminal session using the following command: 

     $HDDL_INSTALL_DIR/bin/hddldaemon
    
  5. Run the docker image by mounting the device drivers

    docker run -it --device --mount type=bind,source=/var/tmp,destination=/var/tmp --device /dev/ion:/dev/ion  onnxruntime-vadm:latest
    
    

OpenVINO on HETERO or Multi-Device Build

  1. Build the docker image from the DockerFile in this repository.

    for HETERO:

     docker build --rm -t onnxruntime-HETERO --build-arg DEVICE=HETERO:<DEVICE_TYPE_1>,<DEVICE_TYPE_2>,<DEVICE_TYPE_3>... --network host -f <Dockerfile> .
    

    for MULTI:

     docker build --rm -t onnxruntime-MULTI --build-arg DEVICE=MULTI:<DEVICE_TYPE_1>,<DEVICE_TYPE_2>,<DEVICE_TYPE_3>... --network host -f <Dockerfile> .
    
  2. Install the required rules, drivers and other packages as required from the steps above for each of the DEVICE_TYPE accordingly that would be added for the HETERO or MULTI Device build type.

  3. Run the docker image as mentioned in the above steps

ARM 32v7

Public Preview

The Dockerfile used in these instructions specifically targets Raspberry Pi 3/3+ running Raspbian Stretch. The same approach should work for other ARM devices, but may require some changes to the Dockerfile such as choosing a different base image (Line 0: FROM ...).

  1. Install dependencies:
  • DockerCE on your development machine by following the instructions here
  • ARM emulator: sudo apt-get install -y qemu-user-static
  1. Create an empty local directory

    mkdir onnx-build
    cd onnx-build
    
  2. Save the Dockerfile from this repo to your new directory: Dockerfile.arm32v7

  3. Run docker build

    This will build all the dependencies first, then build ONNX Runtime and its Python bindings. This will take several hours.

    docker build -t onnxruntime-arm32v7 -f Dockerfile.arm32v7 .
    
  4. Note the full path of the .whl file

    • Reported at the end of the build, after the # Build Output line.
    • It should follow the format onnxruntime-0.3.0-cp35-cp35m-linux_armv7l.whl, but version number may have changed. You'll use this path to extract the wheel file later.
  5. Check that the build succeeded

    Upon completion, you should see an image tagged onnxruntime-arm32v7 in your list of docker images:

    docker images
    
  6. Extract the Python wheel file from the docker image

    (Update the path/version of the .whl file with the one noted in step 5)

    docker create -ti --name onnxruntime_temp onnxruntime-arm32v7 bash
    docker cp onnxruntime_temp:/code/onnxruntime/build/Linux/MinSizeRel/dist/onnxruntime-0.3.0-cp35-cp35m-linux_armv7l.whl .
    docker rm -fv onnxruntime_temp
    

    This will save a copy of the wheel file, onnxruntime-0.3.0-cp35-cp35m-linux_armv7l.whl, to your working directory on your host machine.

  7. Copy the wheel file (onnxruntime-0.3.0-cp35-cp35m-linux_armv7l.whl) to your Raspberry Pi or other ARM device

  8. On device, install the ONNX Runtime wheel file

    sudo apt-get update
    sudo apt-get install -y python3 python3-pip
    pip3 install numpy
    
    # Install ONNX Runtime
    # Important: Update path/version to match the name and location of your .whl file
    pip3 install onnxruntime-0.3.0-cp35-cp35m-linux_armv7l.whl
    
  9. Test installation by following the instructions here

NVIDIA Jetson TX1/TX2/Nano/Xavier:

These instructions are for JetPack SDK 4.4. The Dockerfile.jetson is using NVIDIA L4T 32.4.3 as base image. Versions different from these may require modifications to these instructions. Instructions assume you are on Jetson host in the root of onnxruntime git project clone(https://github.com/microsoft/onnxruntime)

Two-step installation is required:

  1. Build Python 'wheel' for ONNX Runtime on host Jetson system;
  2. Build Docker image using ONNX Runtime wheel from step 1. You can also install the wheel on the host directly.

Here are the build commands for each step:

1.1 Install ONNX Runtime build dependencies on Jetpack 4.4 host:

   sudo apt install -y --no-install-recommends \
    	build-essential software-properties-common cmake libopenblas-dev \
	libpython3.6-dev python3-pip python3-dev

1.2 Build ONNXRuntime Python wheel:

   ./build.sh --update --config Release --build --build_wheel \
   --use_cuda --cuda_home /usr/local/cuda --cudnn_home /usr/lib/aarch64-linux-gnu

Note: You may add --use_tensorrt and --tensorrt_home options if you wish to use NVIDIA TensorRT (support is experimental), as well as any other options supported by build.sh script.

  1. After the Python wheel is successfully built, use 'find' command for Docker to install the wheel inside new image:
   find . -name '*.whl' -print -exec sudo -H DOCKER_BUILDKIT=1 nvidia-docker build --build-arg WHEEL_FILE={} -f ./dockerfiles/Dockerfile.jetson . \;

Note: Resulting Docker image will have ONNX Runtime installed in /usr, and ONNX Runtime wheel copied to /onnxruntime directory. Nothing else from ONNX Runtime source tree will be copied/installed to the image.

Note: When running the container you built in Docker, please either use 'nvidia-docker' command instead of 'docker', or use Docker command-line options to make sure NVIDIA runtime will be used and appropiate files mounted from host. Otherwise, CUDA libraries won't be found. You can also set NVIDIA runtime as default in Docker.

Nuphar

Public Preview

Ubuntu 16.04, Python Bindings

  1. Build the docker image from the Dockerfile in this repository.
docker build -t onnxruntime-nuphar -f Dockerfile.nuphar .
  1. Run the Docker image
docker run -it onnxruntime-nuphar

MIGraphX

Ubuntu 16.04, rocm3.3, AMDMIGraphX v0.7

  1. Build the docker image from the Dockerfile in this repository.
docker build -t onnxruntime-migraphx -f Dockerfile.migraphx .
  1. Run the Docker image
docker run -it --device=/dev/kfd --device=/dev/dri --group-add video onnxruntime-migraphx

ONNX Runtime Server

Public Preview

Ubuntu 16.04

  1. Build the docker image from the Dockerfile in this repository
docker build -t {docker_image_name} -f Dockerfile.server .
  1. Run the ONNXRuntime server with the image created in step 1
docker run -v {localModelAbsoluteFolder}:{dockerModelAbsoluteFolder} -p {your_local_port}:8001 {imageName} --model_path {dockerModelAbsolutePath}
  1. Send HTTP requests to the container running ONNX Runtime Server

Send HTTP requests to the docker container through the binding local port. Here is the full usage document.

curl  -X POST -d "@request.json" -H "Content-Type: application/json" http://0.0.0.0:{your_local_port}/v1/models/mymodel/versions/3:predict