Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Building the python extension fails on Windows 10 #15

Open
joobei opened this issue Jul 8, 2021 · 3 comments
Open

Building the python extension fails on Windows 10 #15

joobei opened this issue Jul 8, 2021 · 3 comments

Comments

@joobei
Copy link

joobei commented Jul 8, 2021

@ptc-lexvandersluijs Which version of python and which version of msvc did you use? When building on windows with VS2017/2019 linking fails with:

[1/1] cl .... /IMPLIB:D:\projects\StableViewSynthesis\ext\mytorch\build\temp.win-amd64-3.8\Release\ext_cpu.cp38-win_amd64.lib
   Creating library D:\projects\StableViewSynthesis\ext\mytorch\build\temp.win-amd64-3.8\Release\ext_cpu.cp38-win_amd64.lib and object D:\projects\StableViewSynthesis\ext\mytorch\build\temp.win-amd64-3.8\Release\ext_cpu.cp38-win_amd64.exp
ext_cpu.obj : error LNK2001: unresolved external symbol "public: long * __cdecl at::Tensor::data_ptr<long>(void)const " (??$data_ptr@J@Tensor@at@@QEBAPEAJXZ)
build\lib.win-amd64-3.8\ext_cpu.cp38-win_amd64.pyd : fatal error LNK1120: 1 unresolved externals
error: command 'D:\\dev\\msvc\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\link.exe' failed with exit status 1120

Seems like the linker cannot find some pytorch library? Any help on debugging this would be appreciated.

@Yuki-F
Copy link

Yuki-F commented Jul 15, 2021

I came across the same problem on building with Windows, and changing all "long" to "int64_t" in all .h, .cpp, .cu files within the mytorch directory solved the issue.
See the link below for details.
https://forums.developer.nvidia.com/t/strange-link-error-seen-by-multiple-people-while-building-pytorch-cpp-cuda-extensions/145261

@Kait0
Copy link

Kait0 commented Feb 17, 2022

Thanks I had the same problem and your solution worked. Wanted to add that i had to exclude the files include/common.h and include/common_cuda.h from this treatment.

@limaodaxia
Copy link

limaodaxia commented Sep 22, 2023

I came across the same problem on building with Windows, and changing all "long" to "int64_t" in all .h, .cpp, .cu files within the mytorch directory solved the issue. See the link below for details. https://forums.developer.nvidia.com/t/strange-link-error-seen-by-multiple-people-while-building-pytorch-cpp-cuda-extensions/145261

Hello,Yuki-F, why change "long" to "int64_t" ? "int64_t" seems not to be a legal datatype? I change "long" to "long long" and it worked.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants