VS2019配置libtorch
下载安装与pytorch对应的libtorch版本,本人使用的是release版本
代码测试
#include<torch/torch.h>
#include<torch/script.h>
#include<iostream>
using namespace std;
int main() {
cout << "安装的 LibTorch 版本 : "
<< TORCH_VERSION_MAJOR << "."
<< TORCH_VERSION_MINOR << "."
<< TORCH_VERSION_PATCH << endl;
cout << "对应的 PyTorch 版本: " << TORCH_VERSION <<endl;
system("pause");
return 0;
}
运行结果
libtorch头文件
#include <torch/script.h>
#include <torch/torch.h>
#include <iostream>