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

开放神经网络交换(ONNX)是一个开放的生态系统,它使人工智能开发人员能够在项目发展过程中选择正确的工具。ONNX为人工智能模型提供了一种开源格式,包括深度学习和传统ML,它定义了一个可扩展的计算图模型,以及内置运算符和标准数据类型的定义。目前我们关注的是推断(评分)所需的能力。

ONNX受到广泛支持,可以在许多框架、工具和硬件中找到。实现不同框架之间的互操作性和简化从研究到生产的路径有助于提高人工智能社区的创新速度。

参考链接:https://github.com/onnx/onnx

Use ONNX

Learn about the ONNX spec

Programming utilities for working with ONNX Graphs

  • Stay up to date with the latest ONNX news. [Facebook] [Twitter]
  • A binary build of ONNX is available from Conda, in conda-forge:
  • You will need an install of Protobuf and NumPy to build ONNX. One easy way to get these dependencies is via Anaconda:
  • You can then install ONNX from PyPi (Note: Set environment variable ONNX_ML=1 for onnx-ml):
  • Alternatively, you can also build and install ONNX locally from source code:
  • 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:
  • Step 1: Build Protobuf locally
  • Step 2: Build ONNX
  • If you would prefer to use Protobuf from conda-forge instead of building Protobuf from source, you can use the following instructions.
  • If you are building ONNX on an ARM 64 device, please make sure to install the dependencies appropriately.
  • After installation, run
  • to verify it works.
  • 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.
  • ONNX uses pytest as test
    driver. In order to run tests, you will first need to install pytest:
  • After installing pytest, use the following command to run tests.
  • Check out the contributor
    guide
    for instructions.

·       Installation

·      
Binaries

·       conda install -c conda-forge onnx

·       Source

·       Linux and MacOS

·       # Use conda-forge protobuf, as default doesn't come with protoc
·       conda install -c conda-forge protobuf numpy
·       pip install onnx
·       git clone https://github.com/onnx/onnx.git
·       cd onnx
·       git submodule update --init --recursive
·       python setup.py install
·       sudo apt-get install protobuf-compiler libprotoc-dev
·       pip install onnx

·       Windows

·       如果在Windows上从源代码构建ONNX,建议也将Protobuf作为静态库在本地构建。与conda-forge一起发布的版本是一个DLL,这是一个冲突,因为ONNX希望它是一个静态库。

·       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
·       # 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

·       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

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

·       Verify Installation

·       python -c "import onnx"

·       Common Errors

·       Testing

·       pip install pytest nbval
·       pytest

·       Development

开放神经网络交换(ONNX)工具的更多相关文章

  1. 开放式神经网络交换-ONNX(下)

    开放式神经网络交换-ONNX(下) 计算节点由名称.它调用的算子operator的名称.命名输入的列表.命名输出的列表和属性列表组成. 输入和输出在位置上与算子operator输入和输出相关联.属性通 ...

  2. 开放式神经网络交换-ONNX(上)

    目的 本文档包含ONNX语义的规范性规范. "onnx"文件夹下的.proto和.proto3文件构成了用协议缓冲区定义语言编写的语法规范..proto和.proto3文件中的注释 ...

  3. LabVIEW开放神经网络交互工具包【ONNX】,大幅降低人工智能开发门槛,实现飞速推理

    前言 前面给大家介绍了自己开发的LabVIEW AI视觉工具包,后来发现有一些onnx模型无法使用opencv dnn加载,且速度也偏慢,所以就有了今天的onnx工具包,如果你想要加载更多模型,追求更 ...

  4. CentOS7 开放端口 通过 firewall-cmd 工具来操作防火墙

    CentOS7 提供了 firewall-cmd 工具来操作防火墙. firewall-cmd --permanent:表示设置为持久,配置被写入配置文件,跨重启,不会立即生效,重新加载配置后生效.不 ...

  5. [.NET6]使用ML.NET+ONNX预训练模型整活B站经典《华强买瓜》

    最近在看微软开源的机器学习框架ML.NET使用别人的预训练模型(开放神经网络交换格式.onnx)来识别图像,然后逛github发现一个好玩的repo.决定整活一期博客. 首先还是稍微科普一下机器学习相 ...

  6. ArXiv最受欢迎开源深度学习框架榜单:TensorFlow第一,PyTorch第四

    [导读]Kears作者François Chollet刚刚在Twitter贴出最近三个月在arXiv提到的深度学习框架,TensorFlow不出意外排名第一,Keras排名第二.随后是Caffe.Py ...

  7. 机器学习框架ML.NET学习笔记【8】目标检测(采用YOLO2模型)

    一.概述 本篇文章介绍通过YOLO模型进行目标识别的应用,原始代码来源于:https://github.com/dotnet/machinelearning-samples 实现的功能是输入一张图片, ...

  8. ApacheCon 首次亚洲大会 —— Incubator 专场介绍

    Apache 孵化器即为想要进入 Apache 软件基金会(ASF)的项目提供相关帮助和服务.它帮助进入的项目(称为"podling")采用 Apache 的治理风格,并引导使用 ...

  9. 由微软打造的深度学习开放联盟ONNX成立

    导读 如今的微软已经一跃成为全球市值最高的高科技公司之一.2018年11月底,微软公司市值曾两次超越了苹果,成为全球市值最高的公司,之后也一直处于与苹果胶着的状态.市场惊叹微软是一家有能力改造自己并取 ...

随机推荐

  1. hdu4287 水题

    题意:          水题,就是给你一些单词,和一些按键记录,问打出下面的那些单词,每一个按键记录一共按了多少次. 思路:       直接把每个单词的每一位转换成数字,然后再把每个单词转换的数字 ...

  2. hdu4861 找规律了

    题意:      给你k个球和一个整数p,每个球的价值是 1^i+2^i+...+(p-1)^i (mod p),两个人轮流取球,最后谁的总价值也大谁就赢,问你先手能不能赢. 思路:      一开始 ...

  3. 病毒木马查杀实战第024篇:MBR病毒之编程解析引导区

    前言 通过之前的学习,相信大家已经对磁盘的引导区有了充分的认识.但是我们之前的学习都是利用现成的工具来对引导区进行解析的,而对于一名反病毒工程师而言,不单单需要有扎实的逆向分析功底,同时也需要有很强的 ...

  4. 编译Android 4.4源代码并烧录到Nexus4

    环境准备: 基本环境:ubuntu-12.04-desktop-64bit(裸机或者Windows下虚拟机安装均可,14.04也可以) 其他要求:空闲磁盘空间100G以上,代码部分接近10G,内存越大 ...

  5. UVA11992不错的线段树段更新

    题意:       给你一个矩阵,最大20*50000的,然后有三个操作 1 x1 y1 x2 y2 v  把子矩阵的值全部都加上v 2 x1 y1 x2 y2 v  把子矩阵的值全部都变成v 2 x ...

  6. PowerShell-1.入门及其常用

    PowerShell可以理解成是加强版的批处理,但是和批处理完全不同,比如可以调用API等.应用场景平时使用的用户机基本都支持了(出了XP). 常用情节:便捷快速开发,或者是**(因为不存在自己的PE ...

  7. Intel汇编程序设计-整数算术指令(上)

    第七章 整数算术指令 7.1 简介 每种汇编语言都有进行操作数移位的指令,移位和循环移位指令在控制硬件设备.加密数据,以及实现高速的图形操作时特别有用.本章讲述如何进行移位和循环移位操作以及如何使用移 ...

  8. Day009 面向对象和方法回顾

    面向过程&面向对象 面向过程思想 步骤清晰简单,第一步做什么,第二步做什么..... 面象过程适合处理一些较为简单的问题 面向对象思想 物以类聚,分类的思维模式,思考问题首先会解决问题需要哪些 ...

  9. Django(5)django配置信息

    前言 Django的配置文件settings.py用于配置整个网站的环境和功能,核心配置必须有项目路径.密钥配置.域名访问权限.App列表.中间件.资源文件.模板配置.数据库的连接方式 基本配置信息 ...

  10. 将项目连接到远程仓库git

    方式一: git clone "git中的项目地址",此时会生成一个新的项目2.该步骤用于生成一个本地仓库 将需要提交的所有文件除了node_module.git以及输出文件dis ...