Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility issues with NumPy 2.0.0 #608

Open
GuangChen2333 opened this issue Jul 13, 2024 · 4 comments
Open

Compatibility issues with NumPy 2.0.0 #608

GuangChen2333 opened this issue Jul 13, 2024 · 4 comments

Comments

@GuangChen2333
Copy link

GuangChen2333 commented Jul 13, 2024

When I run the code

import torch_directml

device = torch_directml.device()

print(device)

I got the error msg:

 A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 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 "D:\JetBrains\PyCharm Professional\plugins\python\helpers\pydev\pydevd.py", line 2252, in <module>
    main()
  File "D:\JetBrains\PyCharm Professional\plugins\python\helpers\pydev\pydevd.py", line 2234, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "D:\JetBrains\PyCharm Professional\plugins\python\helpers\pydev\pydevd.py", line 1544, in run
    return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
  File "D:\JetBrains\PyCharm Professional\plugins\python\helpers\pydev\pydevd.py", line 1551, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "D:\JetBrains\PyCharm Professional\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "E:\Projects\---\main.py", line 1, in <module>
    import torch_directml
  File "E:\Projects\---\.venv\Lib\site-packages\torch_directml\__init__.py", line 94, in <module>
    torch._register_device_module('privateuseone', PrivateUse1Module)
  File "E:\Projects\---\.venv\Lib\site-packages\torch\__init__.py", line 1908, in _register_device_module
    device_type = torch.device(device_type).type
E:\Projects\---\.venv\Lib\site-packages\torch\__init__.py:1908: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:84.)
  device_type = torch.device(device_type).type

Enviroments:

  • Windows 11 23H2 22631.3880
  • Python 3.12
  • torch-directml 0.2.2.dev240614
  • torch 2.3.1
@GongHuilin-DL
Copy link

GongHuilin-DL commented Jul 24, 2024

I got the same error too. My system environment is:

  1. system: Windows 11 专业工作站版
  2. cpu:AMD Ryzen 9 7940HS
  3. python 3.10.13
  4. torch 2.3.1
  5. numpy 2.0.1

@VadimShabashov
Copy link

As a temporary workaround, it helped me to downgrade numpy:

pip install numpy==1.26.4

@GuangChen2333
Copy link
Author

As a temporary workaround, it helped me to downgrade numpy:

pip install numpy==1.26.4

Yes it works. It needs to limit the version or try to become compatible with numpy 2

@joshjkim
Copy link

We're tracking an issue where the latest Windows PyTorch builds are built against numpy<2 pytorch/pytorch#131668. This issue should be fixed in the upcoming PyTorch 2.4.1 release which we plan to add support for

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

No branches or pull requests

4 participants