Skip to main content

基于nvcr.io/nvidia/cuda:11.4.3-cudnn8-devel-ubuntu20.04 构建的1.16.3版本arm64 gpu运行时

Total Downloads
2.0K
1,999
Published
May 17, 2024
2y ago

Get Started

dotnet add package Citms.OnnxRuntime.Gpu-arm64 --version 1.16.3.1
ProductVersions
.NET Standard
netstandard2.0

README

Microsoft.ML.OnnxRuntime.Gpu ARM64

基于ARM服务器编译OnnxRuntime V1.16.3版本GPU依赖库,编译步骤如下

1.下载V1.16.3版本源码

git clone -b v1.16.3 --depth 1 https://github.com/microsoft/onnxruntime.git
git submodule update --init --recursive --progress

2.修改ARM64 cuda dockerfile文件

#进入到下载好的源码目录
cd onnxruntime

cd dockerfiles

#开始修改Dockerfile.cuda文件
  • 原始dockerfile文件内容
# --------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------
# Dockerfile to run ONNXRuntime with CUDA, CUDNN integration

# nVidia cuda 11.4 Base Image
FROM nvcr.io/nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04
ENV         DEBIAN_FRONTEND=noninteractive
MAINTAINER Changming Sun "[email protected]"
ADD . /code

ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
RUN apt-get update && apt-get install -y --no-install-recommends python3-dev ca-certificates g++ python3-numpy gcc make git python3-setuptools python3-wheel python3-packaging python3-pip aria2 && aria2c -q -d /tmp -o cmake-3.26.3-linux-x86_64.tar.gz https://github.com/Kitware/CMake/releases/download/v3.26.3/cmake-3.26.3-linux-x86_64.tar.gz && tar -zxf /tmp/cmake-3.26.3-linux-x86_64.tar.gz --strip=1 -C /usr

RUN cd /code && python3 -m pip install -r tools/ci_build/github/linux/docker/inference/x64/python/cpu/scripts/requireme\
nts.txt && /bin/bash ./build.sh --allow_running_as_root --skip_submodule_sync --cuda_home /usr/local/cuda --cudnn_home /usr/lib/x86_64-linux-gnu/ --use_cuda --config Release --build_wheel --update --build --parallel --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) 'CMAKE_CUDA_ARCHITECTURES=52;60;61;70;75;86'

FROM nvcr.io/nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
ENV         DEBIAN_FRONTEND=noninteractive
COPY --from=0 /code/build/Linux/Release/dist /root
COPY --from=0 /code/dockerfiles/LICENSE-IMAGE.txt /code/LICENSE-IMAGE.txt
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends libstdc++6 ca-certificates python3-setuptools python3-wheel python3-pip unattended-upgrades && unattended-upgrade && python3 -m pip install /root/*.whl && rm -rf /root/*.whl
  • 修改后的文件内容
# --------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------
# Dockerfile to run ONNXRuntime with CUDA, CUDNN integration

# nVidia cuda 11.4 Base Image
FROM nvcr.io/nvidia/cuda:11.4.3-cudnn8-devel-ubuntu20.04
ENV         DEBIAN_FRONTEND=noninteractive
MAINTAINER Changming Sun "[email protected]"
ADD . /code

ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
RUN apt-get update && apt-get install -y --no-install-recommends python3-dev ca-certificates g++ python3-numpy gcc make git python3-setuptools python3-wheel python3-packaging python3-pip aria2 && aria2c -q -d /tmp -o cmake-3.26.3-linux-aarch64.tar.gz https://github.com/Kitware/CMake/releases/download/v3.26.3/cmake-3.26.3-linux-aarch64.tar.gz && tar -zxf /tmp/cmake-3.26.3-linux-aarch64.tar.gz --strip=1 -C /usr

RUN  /bin/bash ./build.sh --allow_running_as_root --skip_submodule_sync --tensorrt_home /usr/lib/aarch64-linux-gnu --cuda_home /usr/local/cuda --cudnn_home /usr/lib/aarch64-linux-gnu/ --use_cuda --config Release --build_shared_lib --build_wheel --update --build --parallel --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) 'CMAKE_CUDA_ARCHITECTURES=52;60;61;70;75;86'
修改点 🐳 修改前📌 修改后
基础镜像 nvcr.io/nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04 nvcr.io/nvidia/cuda:11.4.3-cudnn8-devel-ubuntu20.04
cmake下载地址 cmake-3.26.3-linux-x86_64.tar.gz cmake-3.26.3-linux-aarch64.tar.gz
build.sh cuda+cuDNN路径 /usr/lib/x86_64-linux-gnu /usr/lib/aarch64-linux-gnu

3.开始编译

docker build -t onnxruntime-cuda-build -f Dockerfile.cuda ..

整个执行过程预计2小时,镜像构建完成后,启动容器将文件拷备出来

docker run --rm -it onnxruntime-cuda-build     /bin/bash

# 新开一个shell窗口,其中f96cb33b6482为刚启动的容器id,可通过docker ps进行查看
docker cp f96cb33b6482:/code/build/Linux/Release /root/linux-onnx-cpu
  • 编译后的文件,全都拷贝到宿主机 /root/linux-onnx-cpu目录中了 libonnxruntime.so libonnxruntime_providers_cuda.so libonnxruntime_providers_shared.so 这三个文件是我们需要的最终文件

Downloads by Version

Depended On By

Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

No SPDX license expression is published. Review the license text and your organisation's policy before redistribution.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.