异常0xe06d7363,试图在libtorch中获取张量数据指针时

发布于 2025-02-11 03:45:56 字数 926 浏览 1 评论 0原文

我正在努力写一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文