• Torch 学习


    1. 下载与安装:

    https://pytorch.org/get-started/locally/

    安装cuda9.2 & cudnn https://developer.nvidia.com/rdp/cudnn-download  

    2.  第一个程序

      编写CMakeLists.txt

    cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
    project(simnet)

    set(Torch_DIR "/opensource/libtorch/share/cmake/Torch")

    find_package(Torch REQUIRED)

    message(STATUS "Pytorch status:")
    message(STATUS " libraries: ${TORCH_LIBRARIES}")

    add_executable(simnet run2.cpp)
    add_compile_options(-fpermissive)

    target_link_libraries(simnet ${TORCH_LIBRARIES})
    set_property(TARGET simnet PROPERTY CXX_STANDARD 14)

      编写测试程序

    #include <torch/script.h> // One-stop header.
    
    #include <iostream>
    #include <memory>
    
    int main(int argc, const char* argv[]) {
      if (argc != 2) {
        std::cerr << "usage: example-app <path-to-exported-script-module>
    ";
        return -1;
      }
    
    
      torch::jit::script::Module module;
      try {
        // Deserialize the ScriptModule from a file using torch::jit::load().
        module = torch::jit::load(argv[1]);
      }
      catch (const c10::Error& e) {
        std::cerr << "error loading the model
    ";
        return -1;
      }
    
      std::cout << "ok
    ";
    }
     

    mkdir build 

    cmake .. 

    make

      

  • 相关阅读:
    线段树模板
    树状数组练习
    树状数组模板
    codeforce——思维dp
    fib博弈
    寒假总结
    相邻的数互质
    大数取模运算
    阶乘因式分解(一)
    1和0既非素数也非合数
  • 原文地址:https://www.cnblogs.com/luoyinjie/p/13276060.html
Copyright © 2020-2023  润新知