📔 numpy 版本导致报错


yolov5 PyTorch to ONNX and TorchScript formats 代码运行:

python export.py --weights yolov5s.pt --img 640 --batch 1

由于一些库使用 pip 安装之后,numpy 版本发生冲突,报错如下:

ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
  • 核心原因是 numpy 版本与当前一些库不匹配
  • 通常是因为安装的 numpy 版本过低,把 numpy 更新到最新版本即可

解决方法如下:

pip install --upgrade numpy

📕 CoreML: export failure: Unsupported numpy type: float32

ONNX: export failure: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking arugment for argument index in method wrapper_index_select)
scikit-learn version 0.24.2 is not supported. Minimum required version: 0.17. Maximum required version: 0.19.2. Disabling scikit-learn conversion API.

CoreML: starting export with coremltools 4.1...
Tuple detected at graph output. This will be flattened in the converted model.
Converting graph.
Adding op '1' of type const

CoreML: export failure: Unsupported numpy type: float32

  • 原因是 numpy 版本当前冲突【切换正确版本即可】:pip install numpy==1.19.5

🚀🚀 文末专栏推荐 🚀🚀


  • 👋 如果感觉文章看完了不过瘾,还想更进一步,那么可以来我的其他 专栏 看一下哦~
  • 🎻 个人整理的 Cuda 系列 Linux 安装教程【适合小白进阶】
  • 🍖 深度学习、调参搬砖、开发利器【大佬必备】

❤️ 人生苦短, 欢迎和墨理一起学AI 💜


上一秒的我信誓旦旦

9-5

梦醒,洗头

9-6

9-8

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐