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

TypeError: 'staticmethod' object is not callable #644

Open
pin24 opened this issue Sep 11, 2024 · 4 comments
Open

TypeError: 'staticmethod' object is not callable #644

pin24 opened this issue Sep 11, 2024 · 4 comments

Comments

@pin24
Copy link

pin24 commented Sep 11, 2024

Windows 10
Python 3.8
torch-directml-0.2.4.dev240815

2.3.1+cpu
Traceback (most recent call last):
File "tt_v6.py", line 17, in
import torch_directml
File "C:\Users\Zver.conda\envs\gan\lib\site-packages\torch_directml_init_.py", line 27, in
class PrivateUse1Module:
File "C:\Users\Zver.conda\envs\gan\lib\site-packages\torch_directml_init_.py", line 74, in PrivateUse1Module
def has_float64_support(device_id = default_device()):
TypeError: 'staticmethod' object is not callable

@brazeiro63
Copy link

I've experienced the same problem with version 2.4.1+cpu.
the methods has_float64_support and gpu_memory definitions are calling default_device() directly.
This is causing an error "'staticmethod' object is not callable".

My workaroud:

    @staticmethod
    def has_float64_support(device_id = None):
        if device_id is None:
            device_id = PrivateUse1Module.default_device()
        return torch_directml_native.has_float64_support(device_id)

    @staticmethod
    def gpu_memory(device_id = None, mb_per_tile = 1):
        if device_id is None:
            device_id = PrivateUse1Module.default_device()
        return torch_directml_native.get_gpu_memory(device_id, mb_per_tile)

@devrix123
Copy link

I also got this. what I did was to change the init.py code in the torch_directml library and comment out the @staticmethod code for the default_device() function. after that, I successfully imported the torch_directml library

#@staticmethod
    def default_device() -> int:
        r"""Returns the index of the default selected device."""
        return torch_directml_native.get_default_device()
image

I honestly don't know if what I'm doing is wrong or not.

@k3sh4vk
Copy link

k3sh4vk commented Oct 20, 2024

@pin24 @brazeiro63 @devrix123

The example seems to be working fine in the following configuration without any workarounds -
Python Version = 3.10.11
torch_directml Version = 0.2.5.dev240914

But fails if we try to use python >= 3.7 and < 3.10

It seems that the code in new versions of the torch-directml library is heavily dependent on the new advancements related to staticmethod and classmethod. POINT NO.9 introduced from Python 3.10 onwards.

Here's the PR which introduced this feature.

Image

@danila-permogorskii
Copy link

@pin24 @brazeiro63 @devrix123

The example seems to be working fine in the following configuration without any workarounds - Python Version = 3.10.11 torch_directml Version = 0.2.5.dev240914

But fails if we try to use python >= 3.7 and < 3.10

It seems that the code in new versions of the torch-directml library is heavily dependent on the new advancements related to staticmethod and classmethod. POINT NO.9 introduced from Python 3.10 onwards.

Here's the PR which introduced this feature.

Image

Yeah, it works! Tack så mycket!

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

5 participants