Numpy is not available error

averwhy: <pre><code class="lang-auto">Traceback (most recent call last):                                                           
File "C:\Users\averw\Desktop\repos\vocal-remover\inference.py", line 184, in &lt;module&gt;          
main()
File "C:\Users\averw\Desktop\repos\vocal-remover\inference.py", line 152, in main              y_spec, v_spec = sp.separate(X_spec)                                                           
File "C:\Users\averw\Desktop\repos\vocal-remover\inference.py", line 77, in separate
mask = self._separate(X_mag_pad, roi_size)
File "C:\Users\averw\Desktop\repos\vocal-remover\inference.py", line 42, in _separate          
X_batch = torch.from_numpy(X_batch).to(self.device)                                            
RuntimeError: Numpy is not available
</code></pre>
<p>why is this error happening in PyTorch? I have numpy 1.21.2 installed, and I have PyTorch Nightly with CUDA 11.3</p>

ptrblck: <p>I cannot reproduce the issue, as the installation automatically also installs <code>numpy</code>:</p>
<pre><code class="lang-python">pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cu113/torch_nightly.html
...
Installing collected packages: torch, numpy, torchvision
Successfully installed numpy-1.22.3 torch-1.12.0.dev20220311+cu113 torchvision-0.13.0.dev20220311+cu113
</code></pre>
<p>Manually uninstalling <code>numpy</code> reproduces the error:</p>
<pre><code class="lang-python">python -c "import torch; import numpy as np; print(torch.from_numpy(np.random.randn(1)))"
Traceback (most recent call last):
  File "&lt;string&gt;", line 1, in &lt;module&gt;
ModuleNotFoundError: No module named 'numpy'
</code></pre>
<p>but re-installing it fixes the issue again:</p>
<pre><code class="lang-python">pip install numpy
Collecting numpy
  Using cached numpy-1.22.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.8 MB)
Installing collected packages: numpy
Successfully installed numpy-1.22.3

python -c "import torch; import numpy as np; print(torch.from_numpy(np.random.randn(1)))"
tensor([0.2141], dtype=torch.float64)
</code></pre>

averwhy: <p>Okay, it seems to be because i am on Python 3.10. According to <a href="https://pytorch.org/get-started/locally/#windows-python" rel="noopener nofollow ugc">here,</a> it’s only available through 3.9.</p>

averwhy: <p>Yup, by using <code>py -3.9</code> it works. Solved!</p>

akihironitta: <p>Is there any tracking issue regarding Python 3.10 support on Windows? All I could find is <a href="https://github.com/pytorch/pytorch/issues/66424" class="inline-onebox" rel="noopener nofollow ugc">Add Python-3.10 support · Issue #66424 · pytorch/pytorch · GitHub</a>.</p>

ptrblck: <p>I don’t think the linked issue is Linux-specific and would assume it’s also tracking Windows support.<br>
In any case, are you seeing any issues using the Python 3.10 binaries?</p>

akihironitta: <blockquote>
<p>are you seeing any issues using the Python 3.10 binaries?</p>
</blockquote>
<p><a class="mention" href="/u/ptrblck">@ptrblck</a> Yes (if I’m not missing something). We’re trying to enable testing with Python 3.10 on Linux/macOS/Windows in CI, but it fails only on Windows due to the same error as reported here.</p>
<ul>
<li>PR: <a href="https://github.com/Lightning-AI/metrics/pull/1132#issuecomment-1179978621" class="inline-onebox" rel="noopener nofollow ugc">CI: Enable testing with Python 3.10 by akihironitta · Pull Request #1132 · Lightning-AI/torchmetrics · GitHub</a></li>
<li>on commit <a href="https://github.com/Lightning-AI/metrics/pull/1132/commits/d0afeb4b600c1289d8359f1e82a2d7b4ee68877c" rel="noopener nofollow ugc">d0afeb4</a>
<ul>
<li>CI workflow file: <a href="https://github.com/Lightning-AI/metrics/actions/runs/2646072388/workflow" rel="noopener nofollow ugc">https://github.com/Lightning-AI/metrics/actions/runs/2646072388/workflow</a></li>
<li>CI run failure: <a href="https://github.com/Lightning-AI/metrics/runs/7273421499?check_suite_focus=true" rel="noopener nofollow ugc">https://github.com/Lightning-AI/metrics/runs/7273421499?check_suite_focus=true</a></li>
</ul>
</li>
</ul>
<p>You can see version info in the CI run, but I’m pasting it here for quick access:</p>
<details><summary>pip list</summary>
<pre><code class="lang-auto">absl-py            1.1.0
atomicwrites       1.4.1
attrs              21.4.0
bert-score         0.3.10
build              0.8.0
certifi            2022.6.15
cffi               1.15.1
cfgv               3.3.1
charset-normalizer 2.1.0
check-manifest     0.48
click              8.1.3
cloudpickle        2.1.0
colorama           0.4.5
commonmark         0.9.1
coverage           6.4.1
cycler             0.11.0
distlib            0.3.4
fast-bss-eval      0.1.4
ffmpeg-python      0.2.0
filelock           3.7.1
fire               0.4.0
fonttools          4.34.4
future             0.18.2
Gammatone          1.0
huggingface-hub    0.6.0
identify           2.5.1
idna               3.3
imageio            2.19.3
iniconfig          1.1.1
jiwer              2.3.0
joblib             1.1.0
jsonschema         4.6.2
kiwisolver         1.4.3
llvmlite           0.38.1
lpips              0.1.4
matplotlib         3.5.2
mir-eval           0.7
mock               4.0.3
monotable          3.1.0
musdb              0.4.0
museval            0.4.0
networkx           2.8.4
nltk               3.7
nodeenv            1.7.0
nose               1.3.7
numba              0.55.2
numpy              1.22.4
packaging          21.3
pandas             1.4.3
pep517             0.12.0
pesq               0.0.4
phmdoctest         1.4.0
Pillow             8.4.0
pip                22.1.2
platformdirs       2.5.2
pluggy             1.0.0
portalocker        2.5.1
pre-commit         2.19.0
psutil             5.9.1
py                 1.11.0
pyaml              21.10.1
pycocotools        2.0.4
pycparser          2.21
pyparsing          3.0.9
pypesq             1.2.4
pyrsistent         0.18.1
pystoi             0.3.3
pytest             6.2.5
pytest-cov         3.0.0
pytest-doctestplus 0.12.0
pytest-timeout     2.1.0
python-dateutil    2.8.2
python-Levenshtein 0.12.2
pytorch-msssim     0.2.1
pytz               2022.1
PyWavelets         1.3.0
pywin32            304
PyYAML             6.0
regex              2022.7.9
requests           2.28.1
resampy            0.3.1
rouge-score        0.0.4
sacrebleu          2.1.0
scikit-image       0.19.3
scikit-learn       1.1.0
scipy              1.8.1
setuptools         58.1.0
simplejson         3.17.6
six                1.16.0
SoundFile          0.10.3.post1
speechmetrics      1.0
SRMRpy             1.0
stempeg            0.2.3
tabulate           0.8.10
termcolor          1.1.0
threadpoolctl      3.1.0
tifffile           2022.5.4
tokenizers         0.12.1
toml               0.10.2
tomli              2.0.1
torch              1.12.0+cpu
torch-complex      0.4.3
torch-fidelity     0.3.0
torchmetrics       0.10.0.dev0  d:\a\metrics\metrics\src
torchvision        0.13.0+cpu
tqdm               4.64.0
transformers       4.20.1
typing_extensions  4.3.0
urllib3            1.26.10
virtualenv         20.15.1
</code></pre>
</details>
<hr>
<p><a class="mention" href="/u/ptrblck">@ptrblck</a> I’m confused about whether it’s supported by PyTorch or not, because, as <a class="mention" href="/u/averwhy">@averwhy</a> mentioned above, there is a statement about Python 3.10 on Windows in the official instruction page: <a href="https://pytorch.org/get-started/locally/" class="inline-onebox" rel="noopener nofollow ugc">Start Locally | PyTorch</a></p>
<blockquote>
<p>Currently, PyTorch on Windows only supports Python 3.7-3.9; Python 2.x is not supported.</p>
</blockquote>

ptrblck: <p>I don’t fully understand the linked issue by skimming through it.<br>
It seems you depend on <code>numpy</code> but fail to build it.<br>
However, in your environment you already have <code>numpy</code> installed so could you explain how the <code>numpy</code> issue is related to PyTorch’s Python 3.10 support?</p>