您的当前位置: 网站首页 技术文章 VS2022 libtorch-win-shared-with-deps-2.7.1+cu126 配置记录

VS2022 libtorch-win-shared-with-deps-2.7.1+cu126 配置记录

本文介绍了在Windows系统中配置LibTorch(CUDA 12.6版本)的详细步骤。主要内容包括:下载并解压LibTorch安装包,在VS项目中配置包含目录和库目录,设置附加依赖项(c10.lib,torch.lib等),以及添加特定命令行参数。最后提供了一个简单的测试代码,用于验证CUDA是否可用。整个配置过程涉及VS项目属性设置、路径配置和依赖库...
VS2022 libtorch-win-shared-with-deps-2.7.1+cu126 配置记录

VS2022 libtorch-win-shared-with-deps-2.7.1+cu126 配置记录

1.安装CUDA 略过

2.安装CUDNN 略过

3.下载libtorch-win-shared-with-deps-2.7.1+cu126 解压

LibTorch下载地址

image

4.创建VS项目 略过

5.配置项目环境

5.1 配置包含目录 属性->VC++目录>包含目录

cuda目录\v12.6\include;

libtorch目录\include\torch\csrc\api\include;

libtorch目录\include;

image

5.2 配置库目录 属性->VC++目录>包库目录

libtorch目录\lib;

cuda目录\v12.6\lib\x64;

image

5.3 配置附加依赖项 属性->链接器>输入>附加依赖项

c10.lib libprotobufd.lib dnnl.lib torch.lib torch_cpu.lib c10_cuda.lib torch_cuda.lib

image

5.4 配置命令行 属性->链接器>输入>命令行

/INCLUDE:?warp_size@cuda@at@@YAHXZ

image

6.测试

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

using namespace std;

int main()
{
	if (torch::cuda::is_available())
		cout << "支持CUDA" << endl;
	else
		cout << "不支持CUDA" << endl;
	system("pause");
	return 0;
}

image

评论 (0)

加载中...