抛出 what() numpy 初始化失败'std::runtime_error'实例后调用的终止



环境:基于nvidia/cuda的Docker镜像:11.1-cudnn8-devel-uuntu20.4,python3.8,numpy==1.19.4,opencv=3.4.3。


错误:terminate called after throwing an instance of 'std::runtime_error' what() numpy failed to initializeRuntimeError: module compiled against API version 0xe but this version of numpy is 0xd


此解决方案有助于:pip3 install --upgrade numpy(已成功安装numpy-1.23.0)


描述:python3应用程序在主机ubuntu204.4上使用指定的numpy初始版本成功运行。然而,当在基于相同Ubuntu版本的docker中运行时,它会在指示的错误处停止。解决方案是以所示的形式找到的。然而,为什么主机上和docker容器内的numpy版本存在这种差异,这个问题的本质仍然不清楚。

问题:如果环境的其他部分看起来都一样,为什么主机(1.19.4)和docker容器(1.23.0)内的numpy版本之间的差异会存在。

Pycuda是一个编译包;编译时,它使用numpy的库。

下一个解决方案,允许我使用所需版本的numpy:

pip3 uninstall pycuda -y
pip3 install --upgrade numpy==1.19.4
pip3 install pycuda==2019.1

相关内容