-
Notifications
You must be signed in to change notification settings - Fork 57
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
Set device fails when used after set backend #374
Comments
I can reproduce this issue, and this sounds like the |
A simpler approach could be this: https://docs.python.org/3/faq/programming.html#id11 But probably will break many things, including user custom code. |
Here some short version of the "singleton" approach we discussed today. We place the following code in the class backend:
my_backend_object = 0
_instance = None
def __new__(cls, *args, **kwargs):
if cls._instance is None:
cls._instance = super(backend, cls).__new__(
cls, *args, **kwargs)
return cls._instance
def __repr__(self):
return repr(self.my_backend_object)
K = backend() Then we can import K as usual and get the right object. @stavros11 what do you think? |
Thanks for the details on this. I actually just pushed an update in #370 which I think is very close to this idea, excluding the |
Describe the bug
qibo.set_device()
does not have the expected behavior when used in the same script withqibo.set_backend()
.To Reproduce
will print
"/GPU:0"
if executed in a machine with GPU enabled, as if theqibo.set_device
instruction is ignored. Ifset_backend
is not used thenset_device
works as intended.The text was updated successfully, but these errors were encountered: