Getting same error for numpy 2.0 as of March 18th 2025.
Current solution is to install the latest version of numpy 1 (1.26.4) instead:
Copypip install "numpy<2"
You will likely have to restart the kernel afterwards.
Answer from Talha Tayyab on Stack OverflowIs there somewhere a searchable version compatibility database? As in all python projects reconciling versions is a pretty annoying problem, I meet it again and again.
Currently I try to use pytorch2.3.1 with cuda 11.8 , python 3.11.2 . It seems like I cannot get rid of a warning ( UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:84 ).
Id guess its caused by an incorrect numpy version. Is there a place to look up what combination of torch-cuda-python-numpy is ok and which is not?
Getting same error for numpy 2.0 as of March 18th 2025.
Current solution is to install the latest version of numpy 1 (1.26.4) instead:
Copypip install "numpy<2"
You will likely have to restart the kernel afterwards.
This will be easily solved by upgrading numpy.... When I face this error, that time numpy version 1.22 was installed.... I update version to 1.24.1 using this command
Copypip install numpy==1.24.1
Error Resolved
Videos
Hello, I need help with the problem I'm trying to solve for a few days now. I have to run a project which uses a bunch of packages, including NumPy 1.22 and PyTorch 1.13. I'm using Windows 10 and Python 3.10.11 with pip 23.0.1. When I install the appropriate versions of the packages and try to run the project, I'm getting error: Failed to initialize NumPy: module compiled against API version 0x10 but this version of numpy is 0xf (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:77.). AFAIK 0xf is 1.22 (the version I have installed) and 0x10 is 1.23/1.24.
What I tried:
-
Reinstalling Python including removing everything Python-related (like files in %APPDATA%) to be sure that no versions of NumPy and PyTorch exist in my system (except for packages bundled in some software that I don't want to uninstall).
-
Checking the Path variable to be sure that the correct version of Python and pip is used.
-
Using venv to have a clear environment.
But still somehow torch seems to be installed with NumPy 1.23/1.24 despite the fact that I have no such version of that package in my system (I searched my entire disk). When I import NumPy and print the version and the path, it correctly shows version 1.22 and the path to the package in venv I created.
I also can't update to the newest version of NumPy (or to 1.23/1.24) because then I get incompatibility with SciPy version. I also can't upgrade the project's requirements, the code is from a paper I'm not the author of so it would be cumbersome.
» pip install torch