Hi, want to create a tensor from an existing image buffer copied directly to the GPU during creation,
The model was loaded like this:
mod_ = torch::jit::load("/data/deeplabv3-mobilenetv3-large.pt", torch::Device(torch::kCUDA, 0));
To create the tensor:
torch::from_blob((void*)buffer, {1, 3, 520, 520}, torch::TensorOptions().dtype(torch::kFloat32).device(torch::Device(torch::kCUDA, 0))));
But this fails with this error:
Specified device cuda:0 does not match device of data cuda:-2
I do not understand where this cuda:-2
comes from.
A workaround I found is to create the tensor on CPU and then use tensor.to(cudadevice)
. But I want to understand why the first one fails.