1 Python安装onnxruntime-gpu出错

今天在Anaconda中的虚拟环境中使用

<code class="language-python line-numbers">pip install onnxruntime-gpu
</code>

安装onnxruntime的gpu版本库时出现了如下的错误

<code class="language-python line-numbers">ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'd:\anaconda\envs\vac_cslr\lib\site-packages\numpy-1.23.1.dist-info\METADATA'
</code>

解决方法

这里可能是你的Anaconda的虚拟环境下有多个numpy文件夹,比如上文中我的虚拟环境vac_cslr的路径d:\anaconda\envs\vac_cslr\lib\site-packages就有多个numpy-******类似的文件夹,如

Python – 安装onnxruntime-gpu出现ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: ‘…\\numpy-1.23.1.dist-info\\METADATA’-StubbornHuang Blog

上述错误提示是说d:\anaconda\envs\vac_cslr\lib\site-packages\numpy-1.23.1.dist-info\METADATA这个路径下没有METADATA文件,我们只需要看numpy-1.22.4.dist-info或者numpy-1.21.5.dist-info这两个文件夹中哪个有METADATA文件,然后拷贝到numpy-1.23.1.dist-info文件夹下即可,然后重新运行pip install onnxruntime-gpu即可安装成功!