Skip to content

Fix a problem about numpy - #8

Open
shadow01a wants to merge 1 commit into
adefossez:mainfrom
shadow01a:main
Open

Fix a problem about numpy#8
shadow01a wants to merge 1 commit into
adefossez:mainfrom
shadow01a:main

Conversation

@shadow01a

@shadow01a shadow01a commented Nov 8, 2024

Copy link
Copy Markdown

I'm not good at English, so I use a translator.

I installed demucs using conda as per README. but while using it, it reports an error.

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.2 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

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.

Traceback (most recent call last): File "\?\C:\Users\01.conda\envs\demucs\Scripts\demucs-script.py", line 33, in
sys.exit(load_entry_point('demucs', 'console_scripts', 'demucs')())
File "\?\C:\Users\01.conda\envs\demucs\Scripts\demucs-script.py", line 25, in importlib_load_entry_point
return next(matches).load()
File "C:\Users\01.conda\envs\demucs\lib\importlib\metadata.py", line 86, in load
module = import_module(match.group('module'))
File "C:\Users\01.conda\envs\demucs\lib\importlib_init_.py", line 127, in import_module
return bootstrap.gcd_import(name[level:], package, level)
File "c:\users\01\demucs\demucs\separate.py", line 11, in
from dora.log import fatal
File "C:\Users\01.conda\envs\demucs\lib\site-packages\dora_init
.py", line 66, in
from .explore import Explorer, Launcher
File "C:\Users\01.conda\envs\demucs\lib\site-packages\dora\explore.py", line 27, in
from .shep import Shepherd, Sheep
File "C:\Users\01.conda\envs\demucs\lib\site-packages\dora\shep.py", line 25, in
from .distrib import get_distrib_spec
File "C:\Users\01.conda\envs\demucs\lib\site-packages\dora\distrib.py", line 14, in
import torch
File "C:\Users\01.conda\envs\demucs\lib\site-packages\torch_init
.py", line 1382, in
from .functional import * # noqa: F403
File "C:\Users\01.conda\envs\demucs\lib\site-packages\torch\functional.py", line 7, in
import torch.nn.functional as F
File "C:\Users\01.conda\envs\demucs\lib\site-packages\torch\nn_init_.py", line 1, in
from .modules import * # noqa: F403
File "C:\Users\01.conda\envs\demucs\lib\site-packages\torch\nn\modules_init_.py", line 35, in
from .transformer import TransformerEncoder, TransformerDecoder,
File "C:\Users\01.conda\envs\demucs\lib\site-packages\torch\nn\modules\transformer.py", line 20, in
device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'),
C:\Users\01.conda\envs\demucs\lib\site-packages\torch\nn\modules\transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at C:\actions-runner_work\pytorch\pytorch\builder\windows\pytorch\torch\csrc\utils\tensor_numpy.cpp:84.)
device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'),
c:\users\01\demucs\demucs\api.py:27: UserWarning: TorchAudio's global backend is now deprecated. Please enable distpatcher by setting TORCHAUDIO_USE_BACKEND_DISPATCHER=1, and specify backend when calling load/info/save function.
import torchaudio as ta
Selected model is a bag of 1 models. You will see that many progress bars per track.
Separated tracks will be stored in C:\Users\01\separated\htdemucs
File hdemucs_mmi does not exist. If the path contains spaces, please try again after surrounding the entire path with quotes "".
Separating track C:\Users\01\Music\Mitsukiyo - Honey Jam.mp3
Traceback (most recent call last):
File "\?\C:\Users\01.conda\envs\demucs\Scripts\demucs-script.py", line 33, in
sys.exit(load_entry_point('demucs', 'console_scripts', 'demucs')())
File "c:\users\01\demucs\demucs\separate.py", line 168, in main
origin, res = separator.separate_audio_file(track)
File "c:\users\01\demucs\demucs\api.py", line 308, in separate_audio_file
return self.separate_tensor(self._load_audio(file), self.samplerate)
File "c:\users\01\demucs\demucs\api.py", line 216, in _load_audio
wav = AudioFile(track).read(streams=0, samplerate=self._samplerate,
File "c:\users\01\demucs\demucs\audio.py", line 131, in read
wav = torch.from_numpy(wav)
RuntimeError: Numpy is not available

I found an issue with the same question as mine.It looks like the numpy installation needs to be limited to version 2.0 or less, so I submitted this PR

@shadow01a shadow01a changed the title Fix a problem when conda installs numpy Fix a problem about numpy Nov 9, 2024
@samuelbradshaw

samuelbradshaw commented Aug 15, 2025

Copy link
Copy Markdown

numpy 2 has pretty good support now. I've been running demucs with numpy 2.2.6. Is this still an issue? I'd rather not have my numpy version downgraded to <2.0 if it can be avoided.

@CarlGao4

Copy link
Copy Markdown

Only training requires numpy<2

@cduvenhorst

Copy link
Copy Markdown

The Fix would be to fix the training code instead of tossing the training by simply updating the requirements.

kingjan1999 pushed a commit to kingjan1999/demucs that referenced this pull request Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants