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

Moving a graph to GPU will change the default CUDA device #2895

Closed
chwan1016 opened this issue May 6, 2021 · 1 comment · Fixed by #2897
Closed

Moving a graph to GPU will change the default CUDA device #2895

chwan1016 opened this issue May 6, 2021 · 1 comment · Fixed by #2897

Comments

@chwan1016
Copy link
Contributor

chwan1016 commented May 6, 2021

🐛 Bug

To Reproduce

import torch
import dgl

torch.cuda.set_device(1)
print(torch.cuda.current_device())  # print 1
device = 'cuda'  # 'cuda:1'
g = dgl.graph((torch.tensor([0, 1, 2]), torch.tensor([1, 2, 3]))).to(device)
print(torch.cuda.current_device())  # print 0

Expected behavior

The index of the current device should not be changed.

Environment

  • DGL Version (e.g., 1.0): 0.6
  • Backend Library & Version (e.g., PyTorch 0.4.1, MXNet/Gluon 1.3): PyTorch 1.9.0a0+gitaeaa91b
  • OS (e.g., Linux): RHEL
  • How you installed DGL (conda, pip, source): source
  • Build command you used (if compiling from source):
  • Python version: 3.8
  • CUDA/cuDNN version (if applicable): 11.0
  • GPU models and configuration (e.g. V100): NVIDIA GeForce RTX 2080 Ti
  • Any other relevant information:

Additional context

@chwan1016
Copy link
Contributor Author

chwan1016 commented Aug 17, 2021

This issue should be reopened as it has not been completely solved. @BarclayII @yzh119

import torch
import dgl

torch.cuda.set_device(1)
print(torch.cuda.current_device())  # print 1
device = 'cuda:2'
g = dgl.graph((torch.tensor([0, 1, 2]), torch.tensor([1, 2, 3]))).to(device)
print(torch.cuda.current_device())  # print 2

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

Successfully merging a pull request may close this issue.

1 participant