Skip to content

libtorch 1.8.0 precompiled has no CUDA backend linked (Adding "-INCLUDE:?warp_size@cuda@at@@YAHXZ" no longer helps) #54131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lablabla opened this issue Mar 17, 2021 · 6 comments
Labels
module: windows Windows support for PyTorch

Comments

@lablabla
Copy link

lablabla commented Mar 17, 2021

🐛 Bug

Trying to load JIT torchscript model in Windows 10 using precompiled torch 1.8.0 with CUDA 11.1 results in

Could not run 'aten::empty_strided' with arguments from the 'CUDA' backend. This could be because the operator doesn't exist for this backend, or was omitted during the selective/custom build process (if using custom build).

This was previously solved by adding "-INCLUDE:?warp_size@cuda@at@@YAHXZ" to the linker options of MSVC as suggested here

when moving to 1.8.0 I added torch_cuda_cpp.lib and torch_cuda_cu.lib to the linked libraries

The same torchscript works well in 1.7.1

Environment

  • PyTorch Version (e.g., 1.0): 1.8.0
  • OS (e.g., Linux): Windows 10 (MSVC 2017)
  • How you installed PyTorch (conda, pip, source): Precompiled binaries
  • Build command you used (if compiling from source):
  • Python version: N/A (Libtorch)
  • CUDA/cuDNN version: 11.1
  • GPU models and configuration: Quatro P1000
  • Any other relevant information:

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

@skyline75489
Copy link
Contributor

Hi @lablabla the official way of using LibTorch is through CMake since it handles the trivial linking things. Can you give cmake a try? Also can you share the minimum repro torchscript? I'll see if I can repro this locally.

@mszhanyi mszhanyi added the module: windows Windows support for PyTorch label Mar 17, 2021
@mszhanyi
Copy link
Contributor

mszhanyi commented Mar 17, 2021

@lablabla, could you please refer this command to run your program
cl %BUILDER_ROOT%\test_example_code\check-torch-cuda.cpp torch_cpu.lib c10.lib torch_cuda_cu.lib torch_cuda_cpp.lib /EHsc /link /INCLUDE:?warp_size@cuda@at@@YAHXZ /INCLUDE:?searchsorted_cuda@native@at@@YA?AVTensor@2@AEBV32@0_N1@Z

https://github.com/pytorch/builder/blob/master/test_example_code/check-torch-cuda.cpp

@lablabla
Copy link
Author

@mszhanyi , following your suggestion, I added /INCLUDE:?searchsorted_cuda@native@at@@YA?AVTensor@2@AEBV32@0_N1@Z and now it works, so at least I have a workaround. Thanks!

@skyline75489
I am using CMake to generate the VS project, but I might not be using it correctly using the find_package(torch) and using the generated libraries. I'll adjust my cmake to use it and remove the added /INCLUDE linker options and check again. Also, if the problem will continue I will try and create a minimal torchscript with minimal separate VS project to reproduce. Will report soon. Thanks

@lablabla
Copy link
Author

@skyline75489 using the cmake properly by calling find_package(Torch) and then linking the ${TORCH_LIBRARIES} to the target_link_libraries call fixed the problem.

looking at the linker input, it adds the

-INCLUDE:?searchsorted_cuda@native@at@@YA?AVTensor@2@AEBV32@0_N1@Z
-INCLUDE:?warp_size@cuda@at@@YAHXZ

calls, so it works great now
Closing.

Thanks!

@mszhanyi
Copy link
Contributor

mszhanyi commented Jul 15, 2021

@lablabla @yoshihingis
I write a VS extension to setup libtorch project so users don't need to run cmake again.
So far, it only supports libtorch 1.9 (cpu, cuda102, cuda11.1 in https://pytorch.org/)
The preview version could be download in https://marketplace.visualstudio.com/items?itemName=YiZhang.LibTorch001

The demo video is https://ossci-windows.s3.us-east-1.amazonaws.com/vsextension/demo.mp4.

Any comments are welcome

@rodrigovimieiro
Copy link

/INCLUDE:"?ignore_this_library_placeholder@@YAHXZ"

Worked with:

libtorch 1.12
cuda 11.3
Visual Studio Enterprise 2019
Windows 10

Quoted from:

#37124 (comment)

Although the code compiles fine without it, it throws PyTorch is not linked with support for cuda devices when executed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: windows Windows support for PyTorch
Projects
Status: Done
Development

No branches or pull requests

4 participants