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

are pytorch and tensorflow really using the GPU? #63

Open
BrunoLiegiBastonLiegi opened this issue Feb 7, 2025 · 0 comments
Open

are pytorch and tensorflow really using the GPU? #63

BrunoLiegiBastonLiegi opened this issue Feb 7, 2025 · 0 comments

Comments

@BrunoLiegiBastonLiegi
Copy link
Contributor

BrunoLiegiBastonLiegi commented Feb 7, 2025

Both the backends set the GPU as default device, if available:

self.device = self.np.device("cuda:0" if torch.cuda.is_available() else "cpu")

https://github.com/qiboteam/qiboml/blob/96f7c471286192ef0e43295e811878c57d3acafe/src/qiboml/backends/tensorflow.py#L66C1-L70C46

however, if you try something as simple as:

from qibo import set_backend
from qibo.models import QFT

set_backend(backend="qiboml", platform="pytorch")
c = QFT(5)
r = c()
r.probabilities().device
# device(type='cpu')
r.state().device
# device(type='cpu')

you quickly notice that the GPU was probably not used (the same happens for tf).
At this point we might want to double check that the selected device is used in the computation.

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

1 participant