question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't build windows torchVsion C++ API library

See original GitHub issue

🐛 Describe the bug

  • I try to use TorchVision c++ API in windows10. I follow https://github.com/pytorch/vision Using the models on C++. I download libtorch1.10.1-cu102 and unzip it at D:\thirdpartyforwindows_for_ai\libtorch\libtorch1.10.1-cu102.
git clone https://github.com/pytorch/vision.git
cd vision
git checkout v0.11.2
mkdir build
cd build 
cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DCMAKE_PREFIX_PATH="D:\thirdpartyforwindows_for_ai\libtorch\libtorch1.10.1-cu102;C:\Users\user\Desktop\pybind11\install;C:\Users\user\anaconda3\envs\webv2\libs" -DCMAKE_INSTALL_PREFIX="C:\Users\user\Desktop\torchVision\install" DCMAKE_BUILD_TYPE=Release ..
cmake --build .
  • After Build, I get some error message
D:\thirdpartyforwindows_for_ai\libtorch\libtorch1.10.1-cu102\include\ATen/core/boxing/KernelFunction_impl.h(75): error
C2672: 'c10::KernelFunction::call': 找不到相符的多載函式 [C:\Users\user\Desktop\torchVision\build\torchvision.vcxproj]
D:\thirdpartyforwindows_for_ai\libtorch\libtorch1.10.1-cu102\include\ATen/core/boxing/KernelFunction_impl.h(81): error
C2783: 'Return c10::KernelFunction::call(const c10::OperatorHandle &,c10::DispatchKeySet,Args...) const': 無法針對 'Return'
 推算 樣板 引數 [C:\Users\user\Desktop\torchVision\build\torchvision.vcxproj]
  • Is my Libtorch version wrong? Is there anything wrong with my build steps?

Versions

  • Torch 1.10.1+cu102
  • Torchvision checkout v0.11.2
  • windows10

cc @peterjc123 @nbcsm @guyang3532 @maxluk @gunandrose4u @mszhanyi

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
billy800413commented, Feb 4, 2022

@marcobevih2o For your reference, now I can create the dll in the following way. It still requires python. I changed Visual Studio to 2019 and Torchvision branch is nightly.

git clone https://github.com/pytorch/vision.git
cd vision
git checkout nightly
Download https://download.pytorch.org/libtorch/nightly/cu102/libtorch-win-shared-with-deps-latest.zip
conda create --name test python=3.6
conda activate test
conda install -c conda-forge libjpeg-turbo
conda install -c anaconda libpng
conda install -c anaconda zlib
mkdir build
cd build
SET DISTUTILS_USE_SDK=1
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
cmake -DUSE_PYTHON=OFF -DWITH_CUDA=on -DCMAKE_PREFIX_PATH="C:\Users\user\Desktop\libtorch-win-shared-with-deps-latest\libtorch"  DCMAKE_BUILD_TYPE=Release -A x64 ..
cmake --build . --config Release
0reactions
zhiqwangcommented, Feb 4, 2022

It still requires python.

Seems that that’s a known issue before https://github.com/pytorch/vision/issues/2692#issuecomment-1009783544 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building Torchvision C++ API from source - PyTorch Forums
I have been trying to build torchvision from source (master) on Windows 10. I cannot get past the cmake step. I see there...
Read more >
Can't install pytorch with pip on Windows - Stack Overflow
The most likely reason for Your issue is a 32-bit installation of python, while the torch libraries rely on having a 64-bit version....
Read more >
Installation — MMDetection 2.2.1 documentation
conda install pytorch torchvision -c pytorch. Note: Make sure that your compilation CUDA version and runtime CUDA version match. You can check the...
Read more >
Install PyTorch on Jetson Nano - Q-engineering
This page will guide you through the installation of PyTorch, TorchVision, LibTorch and Caffe2 on a Jetson Nano. PyTorch is a software library...
Read more >
How to set up OpenCV, LibTorch, and Torchvision with Cmake ...
First download the repo from “https://github.com/pytorch/vision” and place it somewhere convenient where you want to keep your cmake libraries.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found