一、下載
https://pytorch.org/
下載release版本并解壓(參考網上博客)
二、vs2017配置
-
右擊解決方案-->屬性-->C/C++-->常規-->附加包含目錄
如圖,添加libtorch下的兩個文件夾
-
右擊解決方案-->屬性-->鏈接器-->常規-->附加目錄項
添加lib路徑
-
右擊解決方案-->屬性-->鏈接器-->輸入-->附加依賴項
c10.lib
c10_cuda.lib
torch_cpu.lib
torch_cuda.lib
torch_cuda_cu.lib
torch_cuda_cpp.lib
-INCLUDE:?warp_size@cuda@at@@YAHXZ
最后一項十分重要
4.右擊解決方案-->屬性-->鏈接器-->輸入-->命令行
三、測試
#include<iostream>
#include<torch/script.h>
#include <torch/torch.h>
#include<memory>
int main()
{
std::cout <<"cuda::is_available():" << torch::cuda::is_available() << std::endl;
system("pause");
}
如果結果為1,則環境配置成功
四、新坑記錄
符合模式選否(默認是)