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?
Best Answer
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
When encountering a runtime error stating that numpy is not available, it means that the numpy library is not installed or not properly configured in the system. Numpy is a fundamental package for scientific computing with Python, and many programs rely on it for numerical operations and data manipulation.
To resolve this issue, the first step is to check if numpy is installed. You can do this by opening a command prompt or terminal and typing 'pip show numpy'. If numpy is not installed, you can install it by running 'pip install numpy'.
If numpy is already installed but the error persists, it might be due to a configuration problem. In such cases, you can try reinstalling numpy by running 'pip uninstall numpy' followed by 'pip install numpy'.
Another possible cause of this error is that the numpy package is installed in a different Python environment or virtual environment. Ensure that you are using the correct environment where numpy is installed. You can check the installed packages in your environment by running 'pip list'.
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.
Instead of usingspect_tensor = torch.from_numpy(spect).double()use thisspect_tensor = torch.tensor(spect).double()
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.