isl-org / StableViewSynthesis

MIT License
213 stars 34 forks source link

Building the python extension fails on Windows 10 #15

Open joobei opened 3 years ago

joobei commented 3 years ago

@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 commented 3 years ago

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 commented 2 years ago

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 commented 1 year ago

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.