10000 torch.device context manager change doesn't show in torch.get_default_device · Issue #131328 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content
torch.device context manager change doesn't show in torch.get_default_device #131328
@kshitij12345

Description

@kshitij12345

🐛 Describe the bug

import torch

def foo(x):
  return torch.ones(x.shape)

x = torch.randn(3)

with torch.device("cuda"):
  print(torch.get_default_device())  # cpu
  print(foo(x))

cc: @ezyang (original author of torch.device as ctx support - #91796)

Versions

main branch

cc @albanD

Metadata

Metadata

Assignees

Labels

bugmodule: python frontendFor issues relating to PyTorch's Python frontendtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0