Skip to content

TorchSharp.Modules.Normal.sample() Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! #618

@toolgood

Description

@toolgood
            var mean = forward(torch.tensor(s, device: config.GetDevice()));
            var log_std = this.log_std.expand_as(mean);
            var std = exp(log_std);
            var dist = new Normal(mean, std);
            var a = dist.sample();// error

图片

error message:

System.Runtime.InteropServices.ExternalException
  HResult=0x80004005
  Message=Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
Exception raised from compute_types at ..\..\aten\src\ATen\TensorIterator.cpp:399 (most recent call first):
00007FFDCED3A29200007FFDCED3A230 c10.dll!c10::Error::Error [<unknown file> @ <unknown line number>]
00007FFDCED39D1E00007FFDCED39CD0 c10.dll!c10::detail::torchCheckFail [<unknown file> @ <unknown line number>]
00007FFDAAE4F6E600007FFDAAE4EF10 torch_cpu.dll!at::TensorIteratorBase::compute_types [<unknown file> @ <unknown line number>]
00007FFDAAE4CBE500007FFDAAE4CB60 torch_cpu.dll!at::TensorIteratorBase::build [<unknown file> @ <unknown line number>]
00007FFDAAE4D1A600007FFDAAE4D0A0 torch_cpu.dll!at::TensorIteratorBase::build_borrowing_binary_op [<unknown file> @ <unknown line number>]
00007FFCE13D363100007FFCE138CF20 torch_cuda_cu.dll!at::cuda::view_as_real [<unknown file> @ <unknown line number>]
00007FFCE1346D3F00007FFCE13085A0 torch_cuda_cu.dll!at::cuda::bucketize_outf [<unknown file> @ <unknown line number>]
00007FFDAB3A4FA500007FFDAB31BF30 torch_cpu.dll!at::TensorMaker::make_tensor [<unknown file> @ <unknown line number>]
00007FFDAB435FF800007FFDAB435F80 torch_cpu.dll!at::_ops::mul_Tensor::redispatch [<unknown file> @ <unknown line number>]
00007FFDAC9382E500007FFDAC937500 torch_cpu.dll!at::redispatch::mul_ [<unknown file> @ <unknown line number>]
00007FFDAC8FA0FA00007FFDAC8EFFF0 torch_cpu.dll!torch::jit::Node::c_ [<unknown file> @ <unknown line number>]
00007FFDAB3EF23300007FFDAB3EF100 torch_cpu.dll!at::_ops::mul_Tensor::call [<unknown file> @ <unknown line number>]
00007FFDAADF786400007FFDAADF7850 torch_cpu.dll!at::Tensor::mul [<unknown file> @ <unknown line number>]
00007FFDBE38C49700007FFDBE38C420 LibTorchSharp.DLL!THSTensor_mul [<unknown file> @ <unknown line number>]
00007FFD6D137E51 <unknown symbol address> !<unknown symbol> [<unknown file> @ <unknown line number>]

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