Git Product home page Git Product logo

Comments (12)

Robertwahl avatar Robertwahl commented on July 21, 2024 1

PyTorch supports the ROCm platform by providing tested wheels packages. To access this feature, go to pytorch.org/get-started/locally/. For the correct wheels command, you must select ‘Linux’, ‘Python’, ‘pip’, and ‘ROCm’ in the matrix. ZLUDA is currently alpha quality, but it has been confirmed to work with a variety of native CUDA applications: Geekbench, 3DF Zephyr, Blender, Reality Capture, LAMMPS, NAMD, waifu2x, OpenFOAM, Arnold (proof of concept) and more. May I inquire what ROCm version you are using? Are you using version 5 or 6? This also appears to be a related question to vosen/ZLUDA#17 . However, AMDGCN uses the same approach with llvm.amdgpu.implicit.offset and __builtin_amdgcn_implicit_offset.

Sources:
https://rocm.docs.amd.com/projects/install-on-linux/en/latest/how-to/3rd-party/pytorch-install.html
https://intel.github.io/llvm-docs/design/CompilerAndRuntimeDesign.html
https://www.youtube.com/watch?v=9y3xpi-yPyA
https://llvm.org/docs/AMDGPUUsage.html
https://intel.github.io/llvm-docs/design/CompilerAndRuntimeDesign.html

from pytorch.

unclemusclez avatar unclemusclez commented on July 21, 2024

PyTorch supports the ROCm platform by providing tested wheels packages. To access this feature, go to pytorch.org/get-started/locally/. For the correct wheels command, you must select ‘Linux’, ‘Python’, ‘pip’, and ‘ROCm’ in the matrix. ZLUDA is currently alpha quality, but it has been confirmed to work with a variety of native CUDA applications: Geekbench, 3DF Zephyr, Blender, Reality Capture, LAMMPS, NAMD, waifu2x, OpenFOAM, Arnold (proof of concept) and more. May I inquire what ROCm version you are using? Are you using version 5 or 6? This also appears to be a related question to vosen/ZLUDA#17 . However, AMDGCN uses the same approach with llvm.amdgpu.implicit.offset and __builtin_amdgcn_implicit_offset.

Sources: https://rocm.docs.amd.com/projects/install-on-linux/en/latest/how-to/3rd-party/pytorch-install.html https://intel.github.io/llvm-docs/design/CompilerAndRuntimeDesign.html https://www.youtube.com/watch?v=9y3xpi-yPyA https://llvm.org/docs/AMDGPUUsage.html https://intel.github.io/llvm-docs/design/CompilerAndRuntimeDesign.html

As I understand it from the general consensus of the community, Zluda is superior to ROCm, even at 6.1 builds. However, this is not my use-case and not really the current issue.

ROCm is unavailable for Windows 10/11 >=6.0. HIP and ROCm libraries are available for Windows with version 5.7.1. PyTorch does not currently support this version of ROCm.

Unfortunately, the proper source code to build ROCm for Windows WSL has not been made available as hsa-runtime-rocr4wsl-amdgpu does not exist: ROCm/ROCm#3051

Therefore, we need ZLUDA to run Python Applications using Pytorch on Windows Machines.
That, and many of the ComfyUI nodes/pretty much any python project that are using Video or Audio models, require CUDA and are specifically designed for CUDA.

ComfyUI is really the main driving force for this, but it's the best. If we want to run it swimmingly on Windows for the foreseeable future, we have to manually patch cpp_extention.py after every update.

from pytorch.

unclemusclez avatar unclemusclez commented on July 21, 2024

for example:

No ROCm runtime is found, using ROCM_HOME='C:\Program Files\AMD\ROCm\5.7'
Traceback (most recent call last):
  File "P:\ComfyUI-ZLUDA\nodes.py", line 1906, in load_custom_node
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "P:\ComfyUI-ZLUDA\custom_nodes\ComfyUI-3D-Pack\__init__.py", line 28, in <module>
    module = importlib.import_module(f".{nodes_filename}", package=__name__)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\musclez\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "P:\ComfyUI-ZLUDA\custom_nodes\ComfyUI-3D-Pack\nodes.py", line 50, in <module>
    from .algorithms.diff_mesh import DiffMesh, DiffMeshCameraController
  File "P:\ComfyUI-ZLUDA\custom_nodes\ComfyUI-3D-Pack\algorithms\diff_mesh.py", line 15, in <module>
    from .diff_mesh_renderer import DiffRastRenderer
  File "P:\ComfyUI-ZLUDA\custom_nodes\ComfyUI-3D-Pack\algorithms\diff_mesh_renderer.py", line 8, in <module>
    import nvdiffrast.torch as dr
  File "P:\ComfyUI-ZLUDA\.venv\Lib\site-packages\nvdiffrast\torch\__init__.py", line 9, in <module>
    from .ops import RasterizeCudaContext, RasterizeGLContext, get_log_level, set_log_level, rasterize, DepthPeeler, interpolate, texture, texture_construct_mip, antialias, antialias_construct_topology_hash
  File "P:\ComfyUI-ZLUDA\.venv\Lib\site-packages\nvdiffrast\torch\ops.py", line 14, in <module>
    import torch.utils.cpp_extension
  File "P:\ComfyUI-ZLUDA\.venv\Lib\site-packages\torch\utils\cpp_extension.py", line 204, in <module>
    HIP_HOME = _join_rocm_home('hip') if ROCM_HOME else None
               ^^^^^^^^^^^^^^^^^^^^^^
  File "P:\ComfyUI-ZLUDA\.venv\Lib\site-packages\torch\utils\cpp_extension.py", line 157, in _join_rocm_home
    raise OSError('Building PyTorch extensions using '
OSError: Building PyTorch extensions using ROCm and Windows is not supported.

then i apply my patch from above:

P:\ComfyUI-ZLUDA\custom_nodes\ComfyUI-3D-Pack\lgm\core\attention.py:22: UserWarning: xFormers is available (Attention)
  warnings.warn("xFormers is available (Attention)")
Total VRAM 20464 MB, total RAM 64662 MB
pytorch version: 2.3.0+cu118
xformers version: 0.0.26.post1+cu118

from pytorch.

Robertwahl avatar Robertwahl commented on July 21, 2024

from pytorch.

unclemusclez avatar unclemusclez commented on July 21, 2024

OSError: Building PyTorch extensions using ROCm and Windows is not supported.

yMqCjPs

it shouldnt be using ROCm for pytorch anway, its CUDA at this point.

from pytorch.

unclemusclez avatar unclemusclez commented on July 21, 2024

P1QoBj6
I've reverted to the original file, pre-patch, and added ROCM_HOME :

No ROCm runtime is found, using ROCM_HOME='C:\Program Files\AMD\ROCm\5.7\'
Traceback (most recent call last):
  File "P:\ComfyUI-ZLUDA\nodes.py", line 1906, in load_custom_node
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "P:\ComfyUI-ZLUDA\custom_nodes\ComfyUI-3D-Pack\__init__.py", line 28, in <module>
    module = importlib.import_module(f".{nodes_filename}", package=__name__)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\musclez\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "P:\ComfyUI-ZLUDA\custom_nodes\ComfyUI-3D-Pack\nodes.py", line 50, in <module>
    from .algorithms.diff_mesh import DiffMesh, DiffMeshCameraController
  File "P:\ComfyUI-ZLUDA\custom_nodes\ComfyUI-3D-Pack\algorithms\diff_mesh.py", line 15, in <module>
    from .diff_mesh_renderer import DiffRastRenderer
  File "P:\ComfyUI-ZLUDA\custom_nodes\ComfyUI-3D-Pack\algorithms\diff_mesh_renderer.py", line 8, in <module>
    import nvdiffrast.torch as dr
  File "P:\ComfyUI-ZLUDA\.venv\Lib\site-packages\nvdiffrast\torch\__init__.py", line 9, in <module>
    from .ops import RasterizeCudaContext, RasterizeGLContext, get_log_level, set_log_level, rasterize, DepthPeeler, interpolate, texture, texture_construct_mip, antialias, antialias_construct_topology_hash
  File "P:\ComfyUI-ZLUDA\.venv\Lib\site-packages\nvdiffrast\torch\ops.py", line 14, in <module>
    import torch.utils.cpp_extension
  File "P:\ComfyUI-ZLUDA\.venv\Lib\site-packages\torch\utils\cpp_extension.py", line 204, in <module>
    HIP_HOME = _join_rocm_home('hip') if ROCM_HOME else None
               ^^^^^^^^^^^^^^^^^^^^^^
  File "P:\ComfyUI-ZLUDA\.venv\Lib\site-packages\torch\utils\cpp_extension.py", line 157, in _join_rocm_home
    raise OSError('Building PyTorch extensions using '
OSError: Building PyTorch extensions using ROCm and Windows is not supported.

from pytorch.

Robertwahl avatar Robertwahl commented on July 21, 2024

from pytorch.

unclemusclez avatar unclemusclez commented on July 21, 2024

Correct, this is my point.

ZLUDA users are required to have ROCm installed, we are using both CUDA and HIP to get ZLUDA to talk to PyTorch.
If ZLUDA users have ROCm installed (which is likely, but this might be the discrepancy)...
https://github.com/lshqqytiger/ZLUDA: "ZLUDA is built purely on ROCm/HIP. On both Windows and Linux."

Pytorch checks for ROCm installations before CUDA installations, and then tries to check against itself if it's a CUDA or ROCm build.

This might be seen as intentional to dissuade people from using a ZLUDA installation to communicate with PyTorch. As I stated my patch works. I am just notifying the PyTorch developers of it.

Since it applies to all PyTorch versions, cpp_extention.py must be manually patched every time. That's fine. It's what we do. However, cpp_extention.py changes depending on which version of PyTorch is being used, hence, I am reaching out.

from pytorch.

unclemusclez avatar unclemusclez commented on July 21, 2024

main...unclemusclez:pytorch:main

from pytorch.

unclemusclez avatar unclemusclez commented on July 21, 2024

perhaps this is obsolete as of 5 days ago: https://www.amd.com/en/resources/support-articles/release-notes/RN-RAD-WIN-24-10-21-01-WSL-2.html AMD ROCM Driver for WSL2 on Windows

from pytorch.

albanD avatar albanD commented on July 21, 2024

Hi,

These scripts have been built organically over the past 6+ years so I wouldn't read any intent in the way they are designed.

We would gladly accept PR fixing this and allowing you to use any tool you want as long as it doesn't conflict with existing things we have already working.

from pytorch.

unclemusclez avatar unclemusclez commented on July 21, 2024

i pretty much just copied and pasted the ZLUDA check code from ComfyUI.

that being said, it may not be necessary as ZLUDA for PyTorch might become obsolete on windows

from pytorch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.