Skip to content
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

How to install torchsparse in Windows10? #12

Closed
Huhaowen0130 opened this issue Nov 28, 2020 · 9 comments
Closed

How to install torchsparse in Windows10? #12

Huhaowen0130 opened this issue Nov 28, 2020 · 9 comments

Comments

@Huhaowen0130
Copy link

No description provided.

@kentang-mit
Copy link
Collaborator

Hi,

I haven't tried the installation on Windows 10. If you encounter any problem when installing torchsparse on Windows10 please reply me in this issue and I will try to figure out the solution.

Best,
Haotian

@zhijian-liu
Copy link
Contributor

I'm closing this issue due to the inactivity. Please feel free to reopen it if the problem has not been resolved.

@weizmanl
Copy link

weizmanl commented Jan 8, 2021

I have Windows 10 and I have been trying to install torchsparse, but no success.

When I run pip things compile, but linkage fails. It says:
Creating library C:\Users\WeizmanL\AppData\Local\Temp\pip-req-build-6qzmrtnx\build\temp.win-amd64-3.8\Release\torchsparse/src\torchsparse_cuda.cp38-win_amd64.lib and object C:\Users\WeizmanL\AppData\Local\Temp\pip-req-build-6qzmrtnx\build\temp.win-amd64-3.8\Release\torchsparse/src\torchsparse_cuda.cp38-win_amd64.exp
hash_cpu.obj : error LNK2001: unresolved external symbol "public: long * __cdecl at::Tensor::data_ptr(void)const " (??$data_ptr@J@Tensor@at@@QEBAPEAJXZ)
build\lib.win-amd64-3.8\torchsparse_cuda.cp38-win_amd64.pyd : fatal error LNK1120: 1 unresolved externals
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\link.exe' failed with exit status 1120

Any ideas?

Thank you

@Huhaowen0130
Copy link
Author

I have Windows 10 and I have been trying to install torchsparse, but no success.

When I run pip things compile, but linkage fails. It says:
Creating library C:\Users\WeizmanL\AppData\Local\Temp\pip-req-build-6qzmrtnx\build\temp.win-amd64-3.8\Release\torchsparse/src\torchsparse_cuda.cp38-win_amd64.lib and object C:\Users\WeizmanL\AppData\Local\Temp\pip-req-build-6qzmrtnx\build\temp.win-amd64-3.8\Release\torchsparse/src\torchsparse_cuda.cp38-win_amd64.exp
hash_cpu.obj : error LNK2001: unresolved external symbol "public: long * __cdecl at::Tensor::data_ptr(void)const " (??$data_ptr@J@Tensor@at@@QEBAPEAJXZ)
build\lib.win-amd64-3.8\torchsparse_cuda.cp38-win_amd64.pyd : fatal error LNK1120: 1 unresolved externals
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\link.exe' failed with exit status 1120

Any ideas?

Thank you

Well, I have tried some solutions about the installation and failed, perhaps it's better to install on linux.

@carlosedubarreto
Copy link

I was able to install making some changes.

First of all, dont do that "ninja" fix. the one that you change "ninja -v" to "ninja --version". This will make your compiling to have new errors that should not be there (like the difficult to compile files that it already have access, I'm saying it because it happened to me 😅)

if you didnt change it, just go to the next step.

I noticed that it was complaining that it was missing some sparsehash include code. ("google/dense_hash_map")
I went to
https://github.com/sparsehash/sparsehash
and got the version 2.0.4

https://github.com/sparsehash/sparsehash/releases/tag/sparsehash-2.0.4

after getting this file, you will have a zip file.
Get the contents that you have in the src folder
image

and paste it on you python enviroment include folder.
in my case it was

C:\Users\Pichau.conda\envs\sparseneus\include

it was like this after i pasted them
image

This will solve the issue of
"google/dense_hash_map"

the other issue I had was related to this error
"public: long * __cdecl at::Tensor::data_ptr(void)const " (??$data_ptr@J@Tensor@at@@QEBAPEAJXZ)

To solve it I saw what was commented on these two places

https://forums.developer.nvidia.com/t/strange-link-error-seen-by-multiple-people-while-building-pytorch-cpp-cuda-extensions/145261

and

isl-org/StableViewSynthesis#15

They say that there is a problem when we try to build on windows, about some type of variables, to change from "long" to "int64_t".

I was able to mae it work changeing these files:
torchsparse\backend\others\query_cuda.cu
torchsparse\backend\others\query_cpu.cpp

torchsparse\backend\hash\hash_cuda.cu
torchsparse\backend\hash\hash_cpu.cpp

to run the installation I ran "python setup.py install"
and it successfully built and installed torchsparse on my venv

image

For people that dont want to change the files from torchsparse by itself, I made a fork and updated those files.
Probably it will be easier to use this repository I forked
https://github.com/carlosedubarreto/torchsparse

Hope it helps

This was referenced Oct 21, 2022
@denred0
Copy link

denred0 commented Nov 22, 2022

I was able to install making some changes.

First of all, dont do that "ninja" fix. the one that you change "ninja -v" to "ninja --version". This will make your compiling to have new errors that should not be there (like the difficult to compile files that it already have access, I'm saying it because it happened to me 😅)

if you didnt change it, just go to the next step.

I noticed that it was complaining that it was missing some sparsehash include code. ("google/dense_hash_map") I went to https://github.com/sparsehash/sparsehash and got the version 2.0.4

https://github.com/sparsehash/sparsehash/releases/tag/sparsehash-2.0.4

after getting this file, you will have a zip file. Get the contents that you have in the src folder image

and paste it on you python enviroment include folder. in my case it was

C:\Users\Pichau.conda\envs\sparseneus\include

it was like this after i pasted them image

This will solve the issue of "google/dense_hash_map"

the other issue I had was related to this error "public: long * __cdecl at::Tensor::data_ptr(void)const " (??$data_ptr@J@Tensor@at@@QEBAPEAJXZ)

To solve it I saw what was commented on these two places

https://forums.developer.nvidia.com/t/strange-link-error-seen-by-multiple-people-while-building-pytorch-cpp-cuda-extensions/145261

and

isl-org/StableViewSynthesis#15

They say that there is a problem when we try to build on windows, about some type of variables, to change from "long" to "int64_t".

I was able to mae it work changeing these files: torchsparse\backend\others\query_cuda.cu torchsparse\backend\others\query_cpu.cpp

torchsparse\backend\hash\hash_cuda.cu torchsparse\backend\hash\hash_cpu.cpp

to run the installation I ran "python setup.py install" and it successfully built and installed torchsparse on my venv

image

For people that dont want to change the files from torchsparse by itself, I made a fork and updated those files. Probably it will be easier to use this repository I forked https://github.com/carlosedubarreto/torchsparse

Hope it helps

Thanks man! You did my day!

@initialneil
Copy link

For anyone reach this issue after 2022.12. With cuda 11.3 or newer maybe, some additional changes are needed for the above post.

  1. Run vcvars64.bat first to enable Visual Studio (to enable cl.exe).
  2. Files in windows also need to be copied to envs's include folder (fix the error of cannot find sparseconfig.h).
  3. Comment out the function in torchsparse\backend\utils\atomic.cuh (fix the error of atomicExch already defined).

@tiancaipipi110
Copy link

tiancaipipi110 commented Feb 1, 2023

I did everything @denred0 and @initialneil suggested, and got two other errors:

  1. ImportError: cannot import name '_nt_quote_args' from 'distutils.spawn'
  2. subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1

To fix these two errors, I downgraded setuptools by conda install -c conda-forge setuptools=59.6 suggested here and changed 'command = ['ninja', '-v']' to 'command = ['ninja', '--version']' in cpp_extension.py suggested in this post

But now I get a LINK : fatal error LNK1181: cannot open input file

OS: Win10
python 3.7.16
torchvision 0.7.0
pytorch 1.6.0
cudatoolkit 10.2.89
cuda 11.7

Here's my vs BuildTools

vs

running install
C:\Users\junew\anaconda3\envs\leRes\lib\site-packages\setuptools\command\install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  setuptools.SetuptoolsDeprecationWarning,
C:\Users\junew\anaconda3\envs\leRes\lib\site-packages\setuptools\command\easy_install.py:159: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  EasyInstallDeprecationWarning,
running bdist_egg
running egg_info
writing torchsparse.egg-info\PKG-INFO
writing dependency_links to torchsparse.egg-info\dependency_links.txt
writing top-level names to torchsparse.egg-info\top_level.txt
reading manifest file 'torchsparse.egg-info\SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'torchsparse.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
C:\Users\junew\anaconda3\envs\leRes\lib\site-packages\torch\utils\cpp_extension.py:270: UserWarning: Error checking compiler version for cl: [WinError 2] The system cannot find the file specified.
  warnings.warn('Error checking compiler version for {}: {}'.format(compiler, error))
building 'torchsparse.backend' extension
Emitting ninja build file C:\Users\junew\anaconda3\envs\LeReS\Lib\site-packages\torchsparse-1.4.0\build\temp.win-amd64-3.7\Release\build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
1.10.2
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.34.31933\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Users\junew\anaconda3\envs\leRes\lib\site-packages\torch\lib /LIBPATH:C:\Users\junew\anaconda3\envs\leRes\libs /LIBPATH:C:\Users\junew\anaconda3\envs\leRes\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.34.31933\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.20348.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\\lib\10.0.20348.0\\um\x64" c10.lib torch.lib torch_cpu.lib torch_python.lib /EXPORT:PyInit_backend C:\Users\junew\anaconda3\envs\LeReS\Lib\site-packages\torchsparse-1.4.0\build\temp.win-amd64-3.7\Release\torchsparse\backend\pybind_cpu.obj C:\Users\junew\anaconda3\envs\LeReS\Lib\site-packages\torchsparse-1.4.0\build\temp.win-amd64-3.7\Release\torchsparse\backend\convolution\convolution_cpu.obj C:\Users\junew\anaconda3\envs\LeReS\Lib\site-packages\torchsparse-1.4.0\build\temp.win-amd64-3.7\Release\torchsparse\backend\devoxelize\devoxelize_cpu.obj C:\Users\junew\anaconda3\envs\LeReS\Lib\site-packages\torchsparse-1.4.0\build\temp.win-amd64-3.7\Release\torchsparse\backend\hash\hash_cpu.obj C:\Users\junew\anaconda3\envs\LeReS\Lib\site-packages\torchsparse-1.4.0\build\temp.win-amd64-3.7\Release\torchsparse\backend\hashmap\hashmap_cpu.obj C:\Users\junew\anaconda3\envs\LeReS\Lib\site-packages\torchsparse-1.4.0\build\temp.win-amd64-3.7\Release\torchsparse\backend\others\count_cpu.obj C:\Users\junew\anaconda3\envs\LeReS\Lib\site-packages\torchsparse-1.4.0\build\temp.win-amd64-3.7\Release\torchsparse\backend\others\query_cpu.obj C:\Users\junew\anaconda3\envs\LeReS\Lib\site-packages\torchsparse-1.4.0\build\temp.win-amd64-3.7\Release\torchsparse\backend\voxelize\voxelize_cpu.obj /OUT:build\lib.win-amd64-3.7\torchsparse\backend.cp37-win_amd64.pyd /IMPLIB:C:\Users\junew\anaconda3\envs\LeReS\Lib\site-packages\torchsparse-1.4.0\build\temp.win-amd64-3.7\Release\torchsparse\backend\backend.cp37-win_amd64.lib
LINK : fatal error LNK1181: cannot open input file 'C:\Users\junew\anaconda3\envs\LeReS\Lib\site-packages\torchsparse-1.4.0\build\temp.win-amd64-3.7\Release\torchsparse\backend\hashmap\hashmap_cpu.obj'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.34.31933\\bin\\HostX86\\x64\\link.exe' failed with exit status 1181

@limaodaxia
Copy link

They say that there is a problem when we try to build on windows, about some type of variables, to change from "long" to "int64_t".

Hello, 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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants