Skip to content

bug when transferring a tensor to pinned memory #1250

@sebffischer

Description

@sebffischer

Not sure why this happens:

> x = torch_tensor(1, device = torch_device("cpu"))
> x$pin_memory(device = torch_device("cpu"))
Error in (function (self, device)  : 
  Attempted to set the storage of a tensor on device "cpu" to a storage on different device "mps:0".  This is no longer allowed; the devices must match.
Exception raised from checkSetStorage at /Users/runner/work/libtorch-mac-m1/libtorch-mac-m1/pytorch/aten/src/ATen/native/Resize.h:139 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) + 52 (0x10367c11c in libc10.dylib)
frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 140 (0x103678d6c in libc10.dylib)
frame #2: void at::native::checkSetStorage<long long>(at::Tensor&, c10::Storage, long long, c10::ArrayRef<long long>, c10::ArrayRef<long long>) + 496 (0x153902bec in libtorch_cpu.dylib)
frame #3: at::native::set_storage_cpu_(at::Tensor&, c10::Storage, long long, c10::ArrayRef<long long>, c10::ArrayRef<
> x$pin_memory()
Error in (function (self, device)  : Expected a torch_device
> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions