错误及解决
- 错误:CUDA support not available with 32-bit windows. Did you forget to set Win64 in the generator target?
- 解决: try to add -DCMAKE_GENERATOR_PLATFORM=x64 to your cmake command
- 错误:vs中找不到torch/torch.h
- 解决:libtorch的头文件路径为:
D:\ainnovation\projects\ciwa\pth_to_cpp\lib\torch\libtorch-win-shared-with-deps-debug-latest\libtorch\include\torch\csrc\api\include
- 错误:在build文件夹下,cmake时报错:
CMake Error: Could not create named generator Visual Studio 15
- 解决:1. 因为装的有cygwin,cygwin里面包含了cmake,所以在环境变量path里面有cygwin的目录。windows平台的cmake的路径在cygwin的后面。因此将cmake的目录路径移到cygwin前面就解决了。2. 见参考文献3
- 错误:在build文件夹下,cmake时报错:
成功的cmake命令(vs2017):cmake -DCMAKE_PREFIX_PATH=libtorch-win-shared-with-deps-debug-latest\libtorch -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 15 Win64" ..
- 错误:PyTorch1.2中某些API更新导致报错
- 解决:
change:
std::shared_ptr<torch::jit::script::Module> module = torch::jit::load(s_model_name);
to:
torch::jit::script::Module module = torch::jit::load(s_model_name, torch::kCUDA);
change:
torch::Tensor out_tensor = module->forward({input_tensor}).toTensor();
to:
torch::Tensor out_tensor = module.forward({input_tensor}).toTensor();
网友评论