日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

开放神经网络交换(ONNX)工具

發(fā)布時間:2023/11/28 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 开放神经网络交换(ONNX)工具 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

開放神經(jīng)網(wǎng)絡(luò)交換(ONNX)工具

開放神經(jīng)網(wǎng)絡(luò)交換(ONNX)是一個開放的生態(tài)系統(tǒng),它使人工智能開發(fā)人員能夠在項目發(fā)展過程中選擇正確的工具。ONNX為人工智能模型提供了一種開源格式,包括深度學(xué)習(xí)和傳統(tǒng)ML,它定義了一個可擴展的計算圖模型,以及內(nèi)置運算符和標(biāo)準(zhǔn)數(shù)據(jù)類型的定義。目前我們關(guān)注的是推斷(評分)所需的能力。

ONNX受到廣泛支持,可以在許多框架、工具和硬件中找到。實現(xiàn)不同框架之間的互操作性和簡化從研究到生產(chǎn)的路徑有助于提高人工智能社區(qū)的創(chuàng)新速度。

參考鏈接:https://github.com/onnx/onnx

Use ONNX

Tutorials for creating ONNX models.
Pre-trained ONNX models

Learn about the ONNX spec

Overview ONNX
intermediate representation spec
Versioning
principles of the spec
Operators
documentation
Python
API Overview

Programming utilities for working with ONNX Graphs

Shape and Type Inference
Graph Optimization
Opset Version Conversion

· Stay up to date with the latest ONNX news. [Facebook] [Twitter]

· Installation

· Binaries

· A binary build of ONNX is available from Conda, in conda-forge:

· conda install -c conda-forge onnx

· Source

· Linux and MacOS

· You will need an install of Protobuf and NumPy to build ONNX. One easy way to get these dependencies is via Anaconda:

· # Use conda-forge protobuf, as default doesn’t come with protoc· conda install -c conda-forge protobuf numpy

· You can then install ONNX from PyPi (Note: Set environment variable ONNX_ML=1 for onnx-ml):

· pip install onnx

· Alternatively, you can also build and install ONNX locally from source code:

· git clone https://github.com/onnx/onnx.git· cd onnx· git submodule update --init --recursive· python setup.py install

· Note: When installing in a non-Anaconda environment, make sure to install the Protobuf compiler before running the pip installation of onnx.
For example, on Ubuntu:

· sudo apt-get install protobuf-compiler libprotoc-dev· pip install onnx

· Windows

· 如果在Windows上從源代碼構(gòu)建ONNX,建議也將Protobuf作為靜態(tài)庫在本地構(gòu)建。與conda-forge一起發(fā)布的版本是一個DLL,這是一個沖突,因為ONNX希望它是一個靜態(tài)庫。

· Step 1: Build Protobuf locally

· git clone https://github.com/protocolbuffers/protobuf.git· cd protobuf· git checkout 3.9.x· cd cmake· # Explicitly set -Dprotobuf_MSVC_STATIC_RUNTIME=OFF to make sure protobuf does not statically link to runtime library· cmake -G “Visual Studio 15 2017 Win64” -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=<protobuf_install_dir>· msbuild protobuf.sln /m /p:Configuration=Release· msbuild INSTALL.vcxproj /p:Configuration=Release

· Step 2: Build ONNX

· # Get ONNX· git clone https://github.com/onnx/onnx.git· cd onnx· git submodule update --init --recursive· · # Set environment variables to find protobuf and turn off static linking of ONNX to runtime library.· # Even better option is to add it to user\system PATH so this step can be performed only once.· # For more details check https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=vs-2017· set PATH=<protobuf_install_dir>\bin;%PATH%· set USE_MSVC_STATIC_RUNTIME=0· · # Optional: Set environment variable ONNX_ML=1 for onnx-ml· · # Build ONNX· python setup.py install

· If you would prefer to use Protobuf from conda-forge instead of building Protobuf from source, you can use the following instructions.

· Build ONNX on Windows with Anaconda

· # Use conda-forge protobuf· conda install -c conda-forge numpy libprotobuf=3.11.3 protobuf· · # Get ONNX· git clone https://github.com/onnx/onnx.git· cd onnx· git submodule update --init --recursive· · # Set environment variable for ONNX to use protobuf shared lib· set USE_MSVC_STATIC_RUNTIME=0· set CMAKE_ARGS="-DONNX_USE_PROTOBUF_SHARED_LIBS=ON -DProtobuf_USE_STATIC_LIBS=OFF -DONNX_USE_LITE_PROTO=ON"· · # Build ONNX· # Optional: Set environment variable ONNX_ML=1 for onnx-ml· · python setup.py install

· Build ONNX on ARM 64

· If you are building ONNX on an ARM 64 device, please make sure to install the dependencies appropriately.

· pip install cython protobuf numpy· sudo apt-get install libprotobuf-dev protobuf-compiler· pip install onnx

· Verify Installation

· After installation, run

· python -c “import onnx”

· to verify it works.

· Common Errors

· Environment variables: USE_MSVC_STATIC_RUNTIME (should be 1 or 0, not
ON or OFF)

· CMake variables: ONNX_USE_PROTOBUF_SHARED_LIBS, Protobuf_USE_STATIC_LIBS

· If ONNX_USE_PROTOBUF_SHARED_LIBS is ON then Protobuf_USE_STATIC_LIBS must be OFF and USE_MSVC_STATIC_RUNTIME must be 0.

If ONNX_USE_PROTOBUF_SHARED_LIBS is OFF then
Protobuf_USE_STATIC_LIBS must be ON and USE_MSVC_STATIC_RUNTIME can be 1 or 0.

· Note that the import onnx command
does not work from the source checkout directory; in this case you’ll see ModuleNotFoundError: No module named
‘onnx.onnx_cpp2py_export’. Change into another directory to fix this error.

· Building ONNX on Ubuntu works well, but on CentOS/RHEL and other ManyLinux systems, you
might need to open the CMakeLists file and replace all instances of /lib with /lib64.

· If you want to build ONNX on Debug mode, remember to set the environment variable DEBUG=1. For debug versions of the dependencies, you need to open the CMakeLists file and append a letter d at the end
of the package name lines. For example, NAMES
protobuf-lite would become NAMES protobuf-lited.

· You can also use the onnx-dev docker image
for a Linux-based installation without having to worry about dependency versioning.

· Testing

· ONNX uses pytest as test driver. In order to run tests, you will first need to install pytest:

· pip install pytest nbval

· After installing pytest, use the following command to run tests.

· pytest

· Development

· Check out the contributor guide for instructions.

總結(jié)

以上是生活随笔為你收集整理的开放神经网络交换(ONNX)工具的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。