配置选项:基于Linux,VScode + libtorch
步骤一:libtorch下载(DEBUG版本)
前往libtorch官网https://pytorch.org/get-started/locally/,选择对应版本的libtorch进行下载
解压完成后,放入D盘或者其他位置,记录其路径即可。
步骤二:安装VScode(这边不再赘述),安装完成后,从官网下载cmake进行安装,这边不推荐通过VScode自带的Extensions增加cmake和cmake tools模块。
步骤三:安装好VScode后,新建项目,然后新建main.cpp,然后逐个配置CMakeLists.txt,launch.json,tasks.json,c_cpp_properties.json文件。
main.cpp 代码如下:
#include<torch/script.h>
#include<torch/torch.h>
using namespace std;
int main()
{
torch::Tensor output;
cout << "cuda is_available: " << torch::cuda::is_available() << endl