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进行推理。
参考:windows10上升级pip
https://jn10010537.blog.csdn.net/article/details/123839978
使用清华镜像源进行加速安装:
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
使用清华镜像源进行加速安装:
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
使用清华镜像源进行加速安装:
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>