广告
返回顶部
首页 > 资讯 > 后端开发 > 其他教程 >VS2022+libtorch+Cuda11.3安装测试教程详解(调用cuda)
  • 1018
分享到

VS2022+libtorch+Cuda11.3安装测试教程详解(调用cuda)

2024-04-02 19:04:59 1018人浏览 独家记忆
摘要

目录1.下载libtorch2.配置Vc++目录:3.配置环境变量:4.配置链接器: 4.1链接器--input5.测试配置结果:参考:以下内容默认cuda已经安装完成并添加至系统环

以下内容默认cuda已经安装完成并添加至系统环境变量

1.下载libtorch

PyTorch

在官网下载压缩包, 可以选择Release版或者Debug版(根据自己需要):

下载完成之后选择安装软件的位置进行解压

2.配置VC++目录:

VS新建空项目

2.1添加包含目录:

D:\soft\libtorch\libtorch\include

D:\soft\libtorch\libtorch\include\torch\csrc\api\include

2.2添加库目录:

D:\soft\libtorch\libtorch\lib

3.配置环境变量:

PATH=D:\soft\libtorch\libtorch\lib;%PATH%

4.配置链接器: 4.1链接器--input

D:\soft\libtorch\libtorch\lib\*.lib

4.2链接器--Command Line

/INCLUDE:?warp_size@cuda@at@@YAHXZ /INCLUDE:?_torch_cuda_cu_linker_symbol_op_cuda@native@at@@YA?AVTensor@2@AEBV32@@Z

5.测试配置结果:

#include<torch/torch.h>
#include<torch/script.h>
#include<iOStream>
 
int main() {
	std::cout << "cuda::is_available():" << torch::cuda::is_available() << std::endl;
	std::cout << "torch::cuda::cudnn_is_available():" << torch::cuda::cudnn_is_available() << std::endl;
	std::cout << "torch::cuda::device_count():" << torch::cuda::device_count() << std::endl;
	torch::Device device(torch::kCUDA);
	torch::Tensor tensor1 = torch::eye(3); // (A) tensor-cpu
	torch::Tensor tensor2 = torch::eye(3, device); // (B) tensor-cuda
	std::cout << tensor1 << std::endl;
	std::cout << tensor2 << std::endl;
}

正常结果输出如下:

参考:

Libtorch + vs 2019安装及配置_开拓者5号的博客-CSDN博客_vs2019配置libtorch

Win10+libtorch+CUDA+vs2017_大智若鱼.AI的博客-CSDN博客

win10系统上LibTorch的安装和使用(cuda10.1版本)_*匿名*的博客-CSDN博客_cuda libtorch

libtorch with Cuda 11.3 not linked properly on windows using Visual Studio 2022 · Issue #72396 · pytorch/pytorch · GitHub

c10::NotImplementedError with minimal example - C++ - PyTorch Forums

到此这篇关于VS2022+libtorch+Cuda11.3安装测试(调用cuda)的文章就介绍到这了,更多相关VS2022 libtorch Cuda11.3安装内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: VS2022+libtorch+Cuda11.3安装测试教程详解(调用cuda)

本文链接: https://www.lsjlt.com/news/148395.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作