pytorch_scatter: Compilation error on Windows 10 with VS2019
Compilation fails with the following error:
...\pytorch_scatter\csrc\cpu\scatter_cpu.cpp(81): error C2975: 'REDUCE': invalid template argument for 'Reducer', expected compile-time constant expression
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 30 (14 by maintainers)
I identified the issue! The following lines are missing in all extensions:
I will run some more tests and will release a new version soon! Sorry for all the trouble đ
Windows installation indeed needs some fixes to Pytorch, see here. I am still unsure why the installation of the binaries does not work for some. Can you try to do:
pip install torch-scatter==latest+cu101 -f http://pytorch-scatter.s3-website.eu-central-1.amazonaws.com/whl/torch-1.4.0.html --trusted-host pytorch-scatter.s3-website.eu-central-1.amazonaws.comworks for me using python 3.7, CUDA10.1, and pytorch 1.4.0. Tested the sample code in the README.md and it is working.
Iâll also mention that I was able to successfully install torch-geometric. To do this I:
pip install torch-scatter==latest+cu101 -f http://pytorch-scatter.s3-website.eu-central-1.amazonaws.com/whl/torch-1.4.0.html --trusted-host pytorch-scatter.s3-website.eu-central-1.amazonaws.compip install torch-sparse==latest+cu101 -f http://pytorch-sparse.s3-website.eu-central-1.amazonaws.com/whl/torch-1.4.0.html --trusted-host pytorch-sparse.s3-website.eu-central-1.amazonaws.compip install torch-clusterpip install torch-geometricYou can now install using HTTPS:
I am also working on a conda package that should eliminate the need of
-finstalls.I applied the potential fix changing âstatic constexpr size_t --> static const size_tâ for all the affected lines in argument_spec.h and module.h as well as the pybind11 cast.h (1449)
return *(this->value);-->return *((type*)this->value);I no longer received the 5 errors earlier posted. However, I was getting link errors after that. I tried python setup.py install again and I didnât get the link error from the previous build but a new one. After I executed âpython setup.py installâ three times it said it installed torch_scatter. The 3 link errors are related to the 3 binaries (_scatter.pyd, _segmetn_coo.pyd, and _segment_csr.pyd) that are produced from the build. E.g.
LINK : error LNK2001: unresolved external symbol PyInit__scatter build\temp.win-amd64-3.7\Release\Development\pytorch_scatter\csrc_scatter.lib : fatal error LNK1120: 1 unresolved externals error: command âC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\bin\HostX86\x64\link.exeâ failed with exit status 1120
After it installed I inspected these files, and all of them were 0 KB in size. So although it said it was successfully built, it did not.
I confirmed this by running the test on the README.md. When trying to import the scatter_max module 3 errors are produced: Failed to load âscatterâ, âsegment_csrâ, and âsegment_cooâ binaries.
Thank you, @rusty1s ! Iâm not using pytorch_scatter, which means Iâm probably in the wrong place, but your link for the Windows install fixed to Pytorch was exactly the solution I needed. Iâm not sure how to get
torch.shto run automatically, using my local paths, but I was able to go through line by line and manually fix my files.Should work again!