libtorch在windows上的调用
转载:https://www.jianshu.com/p/542231f43207
libTorch下载
pytroch为windows端提供了2个版本的预编译好的libTorch动态链接库
Release

image.png
测试环境
- win10 64bit
- vs2017
- libTorch
配置过程
以Debug版本的libTorch为例
- 添加include路径
- 添加链接库lib路径
- 添加lib名称
- 添加环境变量

image.png

image.png

image.png
c10.lib
caffe2.lib
caffe2_detectron_ops.lib
caffe2_module_test_dynamic.lib
clog.lib
cpuinfo.lib
foxi_dummy.lib
foxi_loader.lib
libprotobuf-lited.lib
libprotobufd.lib
libprotocd.lib
onnx.lib
onnxifi_dummy.lib
onnxifi_loader.lib
onnx_proto.lib
torch.lib
测试代码
- demo1
#include<iostream> #include<torch/script.h> int main() { torch::Tensor t1 = torch::tensor({ 10,1,2 }); std::cout << t1[0] << std::endl; system("pause"); }

image.png
- demo2
2个Tensor计算矩阵乘法
#include<iostream> #include<torch/script.h> int main() { auto t1 = torch::tensor({ 1,2,3,4,5,6,7,8,9 }).reshape({ 3,3 }); auto t2 = torch::tensor({ 1,0,2,6,1,1,5,3,2 }).reshape({ 3,3 }); auto t3 = t1.mul(t2); std::cout << t3 << std::endl; system("pause"); }

image.png
作者:侠之大者_7d3f
链接:https://www.jianshu.com/p/542231f43207
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
_________________________________________________________________________________________________________________________________________________
每一个不曾起舞的日子,都是对生命的辜负。
But it is the same with man as with the tree. The more he seeks to rise into the height and light, the more vigorously do his roots struggle earthward, downward, into the dark, the deep - into evil.
其实人跟树是一样的,越是向往高处的阳光,它的根就越要伸向黑暗的地底。----尼采
每一个不曾起舞的日子,都是对生命的辜负。
But it is the same with man as with the tree. The more he seeks to rise into the height and light, the more vigorously do his roots struggle earthward, downward, into the dark, the deep - into evil.
其实人跟树是一样的,越是向往高处的阳光,它的根就越要伸向黑暗的地底。----尼采
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 25岁的心里话
2018-10-17 一个人独立开发 3D 游戏引擎可能吗?
2017-10-17 各领域公开数据集下载
2017-10-17 【Shell脚本】逐行处理文本文件
2017-10-17 cuda9,cuda8分享百度云下载