-
Notifications
You must be signed in to change notification settings - Fork 24.4k
torch.asarray
copy=True
parameter has no effect if device=
is not None
or cpu
#108408
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
Comments
cc @rgommers in case you face the same issue with Array API tests |
@fcharras, the reason is that the index of the device is not specified, and it is judged that it is copied across devices, but in the end, it is found that it belongs to the same device during the copy process, and finally the fast path of function pytorch/torch/csrc/utils/tensor_new.cpp Lines 1702 to 1713 in 4146be1
pytorch/aten/src/ATen/native/TensorConversions.cpp Lines 454 to 464 in 4146be1
pytorch/aten/src/ATen/native/TensorConversions.cpp Lines 378 to 394 in 4146be1
|
Uh oh!
There was an error while loading. Please reload this page.
🐛 Describe the bug
print the same pointers, for instance:
showing that
array
andarray_2
share the same memory (and indeed mutating one will mutate the other), despite passingcopy=True
.(edit: this follow-up snippet
indeed prints
tensor(10., device='cuda:0')
but it should printtensor(0., device='cuda:0')
)
Passing
device="cpu"
ordevice=None
(even if the default device has been set to"cuda"
usingtorch.set_default_device
) does not exhibit the bug.The issue happens not only with
device="cuda"
but also withdevice="mps"
ordevice="xpu"
(relevant issue) providing the respective backends have been installed. So the issue seems to happen before the call is dispatched to the respective backend.Quoting another
asarray
issue that has been recently reported and fixed in #106773 :Versions: latest installed from mamba using get-started instructions:
mamba create -n my_torch_env pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
Versions
cc @ezyang @gchanan @zou3519 @kadeng @albanD
The text was updated successfully, but these errors were encountered: