【问题标题】:how to #include<torch.extension.h> in a .cpp file with Visual Studio?如何使用 Visual Studio 在 .cpp 文件中 #include<torch.extension.h>?
【发布时间】:2020-07-06 22:02:45
【问题描述】:

现在我正在处理一个需要使用 Pytorch C++ 扩展的项目。 我在 python 虚拟环境中安装了 1.4.0 版本的 Pytorch:

activate crfasrnn
>>>import torch
>>>print(torch.__version__)
1.4.0

我使用 Visual Studio 作为 C++ 编译器。 代码是这样的:

#include<iostream>
#include<torch/extension.h>

int main()
{
    std::cout << "hello, world!" << std::endl;
    return 0;
}

但是,编译器告诉我“无法打开 'torch/extension.h'” 我该如何解决这个问题?

【问题讨论】:

    标签: c++ machine-learning computer-vision pytorch


    【解决方案1】:

    您需要从 https://pytorch.org/ 获取适当的 LibTorch 二进制文件,然后在 Visual Studio 中包含所需的二进制文件。 您可以按照here 给出的详细说明进行操作。

    【讨论】:

      猜你喜欢
      • 2020-08-23
      • 1970-01-01
      • 1970-01-01
      • 2019-01-14
      • 2015-07-11
      • 2018-11-06
      • 2021-06-23
      • 2017-08-18
      • 1970-01-01
      相关资源
      最近更新 更多