Reputation: 376
I am running a simple CNN using Pytorch for some audio classification on my Raspberry Pi 4 on Python 3.9.2 (64-bit). For the audio manipulation needed I am using librosa. librosa depends on the numba package which is only compatible with numpy version <= 1.20.
When running my code, the line
spect_tensor = torch.from_numpy(spect).double()
throws the RuntimeError:
RuntimeError: Numpy is not available
Searching the internet for solutions I found upgrading Numpy to the latest version to resolve that specific error, but throwing another error, because Numba only works with Numpy <= 1.20.
Is there a solution to this problem which does not include searching for an alternative to using librosa?
Upvotes: 30
Views: 91525
Reputation: 1
When importing torch you get the following warning:
A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.2 as it may crash... If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2.
Solution:
pip install 'numpy<2'
and don't forget to restart the Kernel.
Upvotes: 0
Reputation: 1
Faced same error while writing code in Notebook Fix : Restart the Kernel.
Upvotes: 0
Reputation: 27575
Getting same error for numpy 2.0
as of October 25th 2024.
Current solution is :
pip install "numpy<2"
Upvotes: 33
Reputation: 21
Issue : Faced same error while writing code for LLMs.(NumPy is not available)
Fix : Restart the Kernel. (Thanks to NPE_Exception for clue, credit goes to this member)
Details : Cause of issue is due to installing packages as found missing while writing code in note book . Looks like should not be done that way. It needs kernel restart to get reference.
Upvotes: 2
Reputation: 381
For some who may be facing this issue in a brand new python environment, you may just have to restart Jupyter Notebook. I received this error simply because I had started up notebook, and then installed numpy in my python environment after realizing it was not previously installed.
If you've done this, just kill the jupyter session and restart. It will pick up the new numpy install.
Upvotes: 11
Reputation: 41
Instead of using spect_tensor = torch.from_numpy(spect).double() use this spect_tensor = torch.tensor(spect).double()
Upvotes: 1
Reputation: 281
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
pip install numpy==1.24.1
Error Resolved
Upvotes: 28
Reputation: 376
Just wanted to give an update on my situation. I downgraded torch to version 0.9.1 which solved the original issue. Now OpenBLAS is throwing a warning because of an open MPLoop. But for now my code is up and running.
Upvotes: 6