# Use linux based pytorch model in windows c++ code

**URL:** <https://discuss.pytorch.org/t/use-linux-based-pytorch-model-in-windows-c-code/57221>\
**Category:** C++\
**Created:** [October 1, 2019, 6:29am UTC](https://discuss.pytorch.org/t/use-linux-based-pytorch-model-in-windows-c-code/57221 "2019-10-01T06:29:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fariha1123](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/f/90ced4/32.png) [@Fariha1123](https://discuss.pytorch.org/u/Fariha1123)\
**Post date:** [October 1, 2019, 6:29am UTC](https://discuss.pytorch.org/t/use-linux-based-pytorch-model-in-windows-c-code/57221/1 "2019-10-01T06:29:50Z")

</div>

I am looking forward to the best way to use my linux based pytorch model to the c++ program in windows.  
Can someone please guide me to the best options?

---

<div class="post-metadata">

**Author:** ![tom](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tom/32/3162_2.png) [@tom](https://discuss.pytorch.org/u/tom)\
**Post date:** [October 1, 2019, 7:40am UTC](https://discuss.pytorch.org/t/use-linux-based-pytorch-model-in-windows-c-code/57221/2 "2019-10-01T07:40:13Z")

</div>

You can follow the [export to C++ tutorial](https://pytorch.org/tutorials/advanced/cpp_export.html), the export format is the same on Windows and Linux, so you can make the step Python on Linux to C++ on Windows.

Best regards

Thomas

---

<div class="post-metadata">

**Author:** ![Fariha1123](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/f/90ced4/32.png) [@Fariha1123](https://discuss.pytorch.org/u/Fariha1123)\
**Post date:** [October 1, 2019, 9:31am UTC](https://discuss.pytorch.org/t/use-linux-based-pytorch-model-in-windows-c-code/57221/3 "2019-10-01T09:31:16Z")

</div>

Thanks, I tried following the tutorial as it is but i am facing issues in building the application via cmake.

This is my error report:

D:\work\torchscript\example-app\example-app\build\>cmake -DCMAKE\_PREFIX\_PATH=D:/work/torchscript/libtorch …  
– Caffe2: CUDA detected: 10.0  
– Caffe2: CUDA nvcc is: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/bin/nvcc.exe  
– Caffe2: CUDA toolkit directory: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0  
CMake Error at D:/work/torchscript/libtorch/share/cmake/Caffe2/public/cuda.cmake:74 (message):  
Caffe2: Couldn’t determine version from header: Change Dir:  
D:/work/torchscript/example-app/example-app/build/dCYT4/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual  
Studio/2017/Professional/MSBuild/15.0/Bin/MSBuild.exe cmTC\_c9077.vcxproj  
/p:Configuration=Debug /p:Platform=x86 /p:VisualStudioVersion=15.0 /v:m &&  
Microsoft ® Build Engine version 15.9.21+g9802d43bc3 for .NET Framework  
Copyright © Microsoft Corporation. All rights reserved.  
C:\Program Files (x86)\Microsoft Visual  
Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets(65,5):  
error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset =  
‘v100’) cannot be found. To build using the v100 build tools, please  
install Visual Studio 2010 build tools. Alternatively, you may upgrade to  
the current Visual Studio tools by selecting the Project menu or  
right-click the solution, and then selecting “Retarget solution”.  
[D:\work\torchscript\example-app\example-app\build\dCYT4\CMakeFiles\CMakeTmp\cmTC\_c9077.vcxproj]

Call Stack (most recent call first):  
D:/work/torchscript/libtorch/share/cmake/Caffe2/Caffe2Config.cmake:88 (include)  
D:/work/torchscript/libtorch/share/cmake/Torch/TorchConfig.cmake:40 (find\_package)  
CMakeLists.txt:4 (find\_package)

– Configuring incomplete, errors occurred!  
See also “D:/work/torchscript/example-app/example-app/build/CMakeFiles/CMakeOutput.log”.  
See also “D:/work/torchscript/example-app/example-app/build/CMakeFiles/CMakeError.log”.

---

<div class="post-metadata">

**Author:** ![tom](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tom/32/3162_2.png) [@tom](https://discuss.pytorch.org/u/tom)\
**Post date:** [October 1, 2019, 11:55am UTC](https://discuss.pytorch.org/t/use-linux-based-pytorch-model-in-windows-c-code/57221/4 "2019-10-01T11:55:20Z")

</div>

So here I must admit that I know next to zero about building things for windows, but if you have the 2010 build tools installed (have you?), you might need to include them into the PATH.  
To me, this seems to be something around how to build general things on Windows more than PyTorch specific.

Best regards

Thomas
