zoukankan      html  css  js  c++  java
  • libtorch配置vs2017

    注意vs2013版本过低,建议用新版本vs

    1、解压libtorch

    进入lib查看拥有的lib文件

     2、添加系统环境(一般是bin,但是libtorch的dll都在lib目录里)

     3、VS新建项目,属性管理器窗口新建自己的属性表

     双击属性表

     

     

     4、解决提醒std冲突问题,项目——属性(注意不是双击属性表,重新从项目——属性进入,属性表设置了不起作用)

    属性->C/C++ ->常规->SDL检查->否

    属性->C/C++ ->语言->符号模式->否

    至此,release模式完毕。

    debug需要把lib目录中的所有dll拷贝到工程目录,或者https://www.cnblogs.com/chinahunter/p/11297778.html

    以后新建项目,加载自己的属性表,设置第4步即可。

    【测试代码】

    #include<iostream>
    #include<torch/script.h>
    int main() {
        torch::Tensor t1 = torch::tensor({ 10,1,2 });
        std::cout << t1[0] << std::endl;
        system("pause");
    }
    //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");
    }
  • 相关阅读:
    linux 硬件信息
    docker note
    Shell cmd set note
    mysql management note
    scp noneed passwd
    update kernel
    数据包处理过程
    tcp/ip分片
    sockopt note
    Python note
  • 原文地址:https://www.cnblogs.com/xixixing/p/12842066.html
Copyright © 2011-2022 走看看