Package | 解决 RuntimeError: Numpy is not available. Failed to initialize NumPy against version 0xf

.

background

Configure the experimental environment in docker, and install the necessary packages according to the command "pip install -r requirement.txt" in the repo . The specific information is as follows.
"
torch==1.8.0
opencv_python==4.5.2.52
trimesh==3.9.8
numpy==1.19.2
pyhocon==0.3.57
icecream==2.1.0
tqdm==4.50.2
scipy==1.7.0
PyMCubes == 0.1.2
"

When running the training, the error is as follows, a very brief error message:
"
RuntimeError: Numpy is not available
"

According to the error message, several blogs were found, and none of the methods were applicable. So I re-read the error message and found a line of User Warning, which reads as follows:
"
/opt/conda/lib/python3.8/site-packages/torch/_masked/__init__.py:223: UserWarning: Failed to initialize NumPy: module compiled against API version 0xf but this version of numpy is 0xd (Triggered internally at /opt/pytorch/pytorch/torch/csrc/utils/tensor_numpy.cpp:68.)

.

solution

According to the information of User Warning, an effective solution was found. The original answer link: github-answer

The reason for this error is that the current numpy version does not match the environment, and it needs to be upgraded. The command is as follows:

pip install numpy --upgrade

problem solved~

I wish you all success in writing code~

.

Guess you like

Origin blog.csdn.net/iLOVEJohnny/article/details/127651663