1、下載libtorch庫
https://pytorch.org/
根據(jù)提示選項選擇下載版本
我選擇的是:
stable1.12.0
Windows
LibTorch
C++/Java
CPU
將下載的壓縮包解壓后放到項目解決方案根目錄中
2、導(dǎo)入庫文件
(1)include
..\libtorch\include\
..\libtorch\include\torch\csrc\api\include
(2)lib
..\libtorch\lib
以及下面的各種.lib文件
3、測試工程代碼
#include <iostream>
#include <torch/torch.h>
int main()
{
torch::Tensor tensor = torch::rand({ 5,3 });
std::cout << tensor << std::endl;
return EXIT_SUCCESS;
}
編譯運行!
O了!
posted on 2022-07-05 18:46
小王 閱讀(453)
評論(0) 編輯 收藏 引用 所屬分類:
LibTorch