jjzjj

【python初级】windows安装onnx、onnxruntime以及onnxruntime-gpu

jn10010537 2023-04-04 原文

【python初级】windows安装onnx、onnxruntime以及onnxruntime-gpu

1、背景

ONNX即Open Neural Network Exchange,开放神经网络交换。
ONNX是一个用于表示深度学习模型的标准,可使模型在不同框架之间进行转移,这个标准对应了.onnx文件格式。

ONNX的规范及代码主要由微软,亚马逊 ,Facebook 和 IBM 等公司共同开发,以开放源代码的方式托管在Github上。

目前官方支持加载ONNX模型并进行推理的深度学习框架有: Caffe2, PyTorch, MXNet,ML.NET,TensorRT 和 Microsoft CNTK,并且 TensorFlow 也非官方的支持ONNX。

注意安装onnx,可以进行网络模型的操作。
ONNX Runtime是将 ONNX 模型部署到生产环境的跨平台高性能运行引擎。
ONNX Runtime跨平台,适用于 Linux、Windows 和 Mac。它还具有C++、 C、Python 和C# api。 ONNX Runtime为所有 ONNX 规范提供支持,并与不同硬件(如 TensorRT 上的 NVidia-GPU)上的加速器集成。

可以简单理解为:
安装了onnxruntime,支持使用cpu进行推理,
安装了onnxruntime-gpu,支持使用英伟达GPU进行推理。

2、升级pip

参考:windows10上升级pip
https://jn10010537.blog.csdn.net/article/details/123839978

3、pip安装onnx

使用清华镜像源进行加速安装:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple onnx

安装日志如下:

C:\Users\Administrator>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple onnx
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting onnx
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/73/19/048a3c75d315b5b4b739b57be446393ec94c207320923e9d47f8ee9a1bd6/onnx-1.11.0-cp38-cp38-win_amd64.whl (11.2 MB)
     ---------------------------------------- 11.2/11.2 MB 1.6 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.16.6 in d:\d02_pythondevelop\d02_01_python3\install_python3.8.8\lib\site-packages (from onnx) (1.22.3)
Collecting protobuf>=3.12.2
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/11/8f/3703b61ee707fbd9ea683d1642392af41338b8cd71d7fda76fc002a7e939/protobuf-3.19.4-cp38-cp38-win_amd64.whl (895 kB)
     ---------------------------------------- 895.9/895.9 KB 976.4 kB/s eta 0:00:00
Requirement already satisfied: typing-extensions>=3.6.2.1 in d:\d02_pythondevelop\d02_01_python3\install_python3.8.8\lib\site-packages (from onnx) (4.1.1)
Installing collected packages: protobuf, onnx
Successfully installed onnx-1.11.0 protobuf-3.19.4

C:\Users\Administrator>pip list

4、pip安装onnxruntime

使用清华镜像源进行加速安装:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple onnxruntime

安装日志如下:

F:\A02_AIFramework\ultralytics_yolov5\Releases_Tags\Releases_v6.1\yolov5-6.1>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple onnxruntime
WARNING: Ignore distutils configs in setup.cfg due to encoding errors.
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting onnxruntime
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ca/5f/fa9c1d2ac6a573e4ccba2ab760dbf464d8dd4cfcda700bd30ab18b07e004/onnxruntime-1.11.0-cp38-cp38-win_amd64.whl (5.5 MB)
     ---------------------------------------- 5.5/5.5 MB 1.3 MB/s eta 0:00:00
Requirement already satisfied: protobuf in d:\d02_pythondevelop\d02_01_python3\install_python3.8.8\lib\site-packages (from onnxruntime) (3.19.4)
Collecting flatbuffers
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3d/d0/26033c70d642fbc1e35d3619cf3210986fb953c173b1226709f75056c149/flatbuffers-2.0-py2.py3-none-any.whl (26 kB)
Requirement already satisfied: numpy>=1.22.3 in d:\d02_pythondevelop\d02_01_python3\install_python3.8.8\lib\site-packages (from onnxruntime) (1.22.3)
Installing collected packages: flatbuffers, onnxruntime
  WARNING: Ignore distutils configs in setup.cfg due to encoding errors.
  WARNING: Ignore distutils configs in setup.cfg due to encoding errors.
WARNING: Ignore distutils configs in setup.cfg due to encoding errors.
Successfully installed flatbuffers-2.0 onnxruntime-1.11.0

F:\A02_AIFramework\ultralytics_yolov5\Releases_Tags\Releases_v6.1\yolov5-6.1>python detect.py --weights weights\yolov5l.onnx

5、pip安装onnxruntime-gpu

使用清华镜像源进行加速安装:
pip install onnxruntime-gpu -i https://pypi.tuna.tsinghua.edu.cn/simple

安装日志如下:

F:\A02_AIFramework\ultralytics_yolov5\Releases_Tags\Releases_v6.1\yolov5-6.1>pip install onnxruntime-gpu  -i https://pypi.tuna.tsinghua.edu.cn/simple
WARNING: Ignore distutils configs in setup.cfg due to encoding errors.
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting onnxruntime-gpu
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/71/51/c84530c0b458a85e9761e94c5ba9af1606eb0594638bf0778a75d6c5a955/onnxruntime_gpu-1.11.0-cp38-cp38-win_amd64.whl (109.0 MB)
     ---------------------------------------- 109.0/109.0 MB 579.2 kB/s eta 0:00:00
Requirement already satisfied: protobuf in d:\d02_pythondevelop\d02_01_python3\install_python3.8.8\lib\site-packages (from onnxruntime-gpu) (3.19.4)
Requirement already satisfied: numpy>=1.22.3 in d:\d02_pythondevelop\d02_01_python3\install_python3.8.8\lib\site-packages (from onnxruntime-gpu) (1.22.3)
Requirement already satisfied: flatbuffers in d:\d02_pythondevelop\d02_01_python3\install_python3.8.8\lib\site-packages (from onnxruntime-gpu) (2.0)
Installing collected packages: onnxruntime-gpu
  WARNING: Ignore distutils configs in setup.cfg due to encoding errors.
WARNING: Ignore distutils configs in setup.cfg due to encoding errors.
Successfully installed onnxruntime-gpu-1.11.0

F:\A02_AIFramework\ultralytics_yolov5\Releases_Tags\Releases_v6.1\yolov5-6.1>

有关【python初级】windows安装onnx、onnxruntime以及onnxruntime-gpu的更多相关文章

  1. ruby - 在 Ruby 程序执行时阻止 Windows 7 PC 进入休眠状态 - 2

    我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0

  2. python - 如何使用 Ruby 或 Python 创建一系列高音调和低音调的蜂鸣声? - 2

    关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。

  3. ruby - 在 64 位 Snow Leopard 上使用 rvm、postgres 9.0、ruby 1.9.2-p136 安装 pg gem 时出现问题 - 2

    我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po

  4. ruby - 什么是填充的 Base64 编码字符串以及如何在 ruby​​ 中生成它们? - 2

    我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%

  5. ruby - 完全离线安装RVM - 2

    我打算为ruby​​脚本创建一个安装程序,但我希望能够确保机器安装了RVM。有没有一种方法可以完全离线安装RVM并且不引人注目(通过不引人注目,就像创建一个可以做所有事情的脚本而不是要求用户向他们的bash_profile或bashrc添加一些东西)我不是要脚本本身,只是一个关于如何走这条路的快速指针(如果可能的话)。我们还研究了这个很有帮助的问题:RVM-isthereawayforsimpleofflineinstall?但有点误导,因为答案只向我们展示了如何离线在RVM中安装ruby。我们需要能够离线安装RVM本身,并查看脚本https://raw.github.com/wayn

  6. ruby-on-rails - rails 目前在重启后没有安装 - 2

    我有一个奇怪的问题:我在rvm上安装了ruby​​onrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(

  7. ruby - 如何为 emacs 安装 ruby​​-mode - 2

    我刚刚为fedora安装了emacs。我想用emacs编写ruby。为ruby​​提供代码提示、代码完成类型功能所需的工具、扩展是什么? 最佳答案 ruby-mode已经包含在Emacs23之后的版本中。不过,它也可以通过ELPA获得。您可能感兴趣的其他一些事情是集成RVM、feature-mode(Cucumber)、rspec-mode、ruby-electric、inf-ruby、rinari(用于Rails)等。这是我当前用于Ruby开发的Emacs配置:https://github.com/citizen428/emacs

  8. ruby-on-rails - 无法在centos上安装therubyracer(V8和GCC出错) - 2

    我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e

  9. ruby - 通过 RVM (OSX Mountain Lion) 安装 Ruby 2.0.0-p247 时遇到问题 - 2

    我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search

  10. ruby - 如何在 Lion 上安装 Xcode 4.6,需要用 RVM 升级 ruby - 2

    我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121

随机推荐