异常0xe06d7363,试图在libtorch中获取张量数据指针时
我正在努力写一个CUDA操作员。数据的地址指针应传递到操作员。但是我遇到了这个例外,因为你会吼叫。
异常被像以下代码一样抛出:
#include <iostream>
#include <torch/serialize/tensor.h>
#include <ATen/cuda/CUDAContext.h>
int main() {
// note that whether on gpu or cpu, the exception is the same
auto options = at::TensorOptions().dtype(torch::kInt64).device(torch::kCUDA, 0);
auto x = at::arange(0, 10, options);
// get the pointer of data
int* x_ptr = x.data_ptr<int>(); // where the exception is thrown out
std::cout << "x[0]: " << x_ptr[0] << std::endl; // print out
// ....
// pass x_ptr into operator function
// ...
}
在CPU上,异常:异常0xE06D7363在地址遇到的0x7ffd416f4f4f4f6
在CUDA上,例外0xE06D7363在地址0x7ffd416f4f4f4f69
:win10
Platporl> Platform> Platporl compiator:win fins:win fins. 2022 CL版本19.31.31107
I'm struggling to write a CUDA operator. The address pointer of the data should be passed into the operator. But I met this exception as you can bellow.
The exception is thrown out like this code:
#include <iostream>
#include <torch/serialize/tensor.h>
#include <ATen/cuda/CUDAContext.h>
int main() {
// note that whether on gpu or cpu, the exception is the same
auto options = at::TensorOptions().dtype(torch::kInt64).device(torch::kCUDA, 0);
auto x = at::arange(0, 10, options);
// get the pointer of data
int* x_ptr = x.data_ptr<int>(); // where the exception is thrown out
std::cout << "x[0]: " << x_ptr[0] << std::endl; // print out
// ....
// pass x_ptr into operator function
// ...
}
on cpu, exception: Exception 0xe06d7363 encountered at address 0x7ffd416f4f6
on CUDA, Exception 0xe06d7363 encountered at address 0x7ffd416f4f69
platform: win10
compiler: visual studio 2022 cl version 19.31.31107
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论