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

Error occured when testing the PoinTr pretrained model on the PCN benchmark : "Error building extension 'knn' " #21

Closed
LeiKeRrr opened this issue Dec 3, 2021 · 8 comments
Labels

Comments

@LeiKeRrr
Copy link

LeiKeRrr commented Dec 3, 2021

Hi !

I am trying to test the PoinTr pretrained model on the PCN benchmark but I get this error :

`C:\Repos\PoinTr-master>bash ./scripts/test.sh 0
--ckpts ./pretrained/PoinTr_PCN.pth
--config ./cfgs/PCN_models/PoinTr.yaml
--exp_name example

  • GPUS=0
  • PY_ARGS=''
  • CUDA_VISIBLE_DEVICES=0
  • /mnt/c/Users/peter/AppData/Local/Programs/Python/Python39/python.exe main.py --test ''
    Traceback (most recent call last):
    File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 1717, in _run_ninja_build
    subprocess.run(
    File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
    subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Repos\PoinTr-master\main.py", line 1, in
from tools import run_net
File "C:\Repos\PoinTr-master\tools_init_.py", line 1, in
from .runner import run_net
File "C:\Repos\PoinTr-master\tools\runner.py", line 5, in
from tools import builder
File "C:\Repos\PoinTr-master\tools\builder.py", line 8, in
from models import build_model_from_cfg
File "C:\Repos\PoinTr-master\models_init_.py", line 3, in
import models.PoinTr
File "C:\Repos\PoinTr-master\models\PoinTr.py", line 6, in
from .Transformer import PCTransformer
File "C:\Repos\PoinTr-master\models\Transformer.py", line 6, in
from .dgcnn_group import DGCNN_Grouper
File "C:\Repos\PoinTr-master\models\dgcnn_group.py", line 4, in
from knn_cuda import KNN
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\knn_cuda_init_.py", line 38, in
knn = load_cpp_ext("knn")
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\knn_cuda_init
.py", line 26, in load_cpp_ext
ext = load(
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 1124, in load
return _jit_compile(
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 1337, in _jit_compile
_write_ninja_file_and_build_library(
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 1449, in _write_ninja_file_and_build_library
_run_ninja_build(
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 1733, in _run_ninja_build
raise RuntimeError(message) from e
RuntimeError: Error building extension 'knn': [1/1] "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64/link.exe" knn.o knn.cuda.o /nologo /DLL c10.lib c10_cuda.lib torch_cpu.lib torch
_cuda.lib -INCLUDE:?warp_size@cuda@at@@yahxz torch.lib /LIBPATH:C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\lib torch_python.lib /LIBPATH:C:\Users\peter\AppData\Local\Programs\Python\Python39\libs "/LIBP
ATH:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\lib/x64" cudart.lib /out:knn.pyd
FAILED: knn.pyd
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64/link.exe" knn.o knn.cuda.o /nologo /DLL c10.lib c10_cuda.lib torch_cpu.lib torch_cuda.lib -INCLUDE:?warp_size@cuda@at@@yahxz torch.l
ib /LIBPATH:C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\lib torch_python.lib /LIBPATH:C:\Users\peter\AppData\Local\Programs\Python\Python39\libs "/LIBPATH:C:\Program Files\NVIDIA GPU Computing Toolkit\CU
DA\v10.2\lib/x64" cudart.lib /out:knn.pyd
CrÚation de la bibliothÞque knn.lib et de l'objet knn.exp
knn.o : error LNK2019: symbole externe non rÚsolu "public: long * __cdecl at::TensorBase::data_ptr(void)const " (??$data_ptr@J@TensorBase@at@@QEBAPEAJXZ) rÚfÚrencÚ dans la fonction "public: long * __cdecl at::Tensor::data(voi
d)const " (??$data@J@Tensor@at@@QEBAPEAJXZ)
knn.pyd : fatal error LNK1120: 1 externes non rÚsolus
ninja: build stopped: subcommand failed.`

I have already done the solution for the commun bug in the chamfer distance installation (issue #6 ).

I am on Windows and I was wondering if this error could come from an error when building pytorch extensions.

@yuxumin
Copy link
Owner

yuxumin commented Dec 3, 2021

Hi, @LeiKeRrr. According to the log above, it seems that you have failed to install the knn_cuda package. Make sure that the cudatoolkit version of your pytorch matches the cuda version in your system (nvcc -V).

@LeiKeRrr
Copy link
Author

LeiKeRrr commented Dec 5, 2021

Hi !

Thank you for your quick answer and sorry for my late reply...

I checked that the two versions match, and they do. I also get an error when running the command bash install.sh when building the gridding extension :

`Installed c:\users\peter\appdata\roaming\python\python39\site-packages\cubic_feature_sampling-1.1.0-py3.9-win-amd64.egg
Processing dependencies for cubic-feature-sampling==1.1.0
Finished processing dependencies for cubic-feature-sampling==1.1.0
running install
running bdist_egg
running egg_info
writing gridding.egg-info\PKG-INFO
writing dependency_links to gridding.egg-info\dependency_links.txt
writing top-level names to gridding.egg-info\top_level.txt
reading manifest file 'gridding.egg-info\SOURCES.txt'
writing manifest file 'gridding.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_ext
building 'gridding' extension
Emitting ninja build file C:\Repos\PoinTr-master\extensions\gridding\build\temp.win-amd64-3.9\Release\build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
[1/1] C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin\nvcc --generate-dependencies-with-compile --dependency-output C:\Repos\PoinTr-master\extensions\gridding\build\temp.win-amd64-3.9\Release\gridding_reverse.obj.d --use-loc
al-env -Xcompiler /MD -Xcompiler /wd4819 -Xcompiler /wd4251 -Xcompiler /wd4244 -Xcompiler /wd4267 -Xcompiler /wd4275 -Xcompiler /wd4018 -Xcompiler /wd4190 -Xcompiler /EHsc -Xcudafe --diag_suppress=base_class_has_different_dll_interface -
Xcudafe --diag_suppress=field_without_dll_interface -Xcudafe --diag_suppress=dll_interface_conflict_none_assumed -Xcudafe --diag_suppress=dll_interface_conflict_dllexport_assumed -IC:\Users\peter\AppData\Local\Programs\Python\Python39\li
b\site-packages\torch\include -IC:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\include\torch\csrc\api\include -IC:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\include\TH -IC:
Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\include\THC "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\include" -IC:\Users\peter\AppData\Local\Programs\Python\Python39\include -IC:\Users\peter
AppData\Local\Programs\Python\Python39\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.2
8.29333\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Fi
les (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" -c C:\Repos\PoinTr-master\extensions\griddi
ng\gridding_reverse.cu -o C:\Repos\PoinTr-master\extensions\gridding\build\temp.win-amd64-3.9\Release\gridding_reverse.obj -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_O
PERATORS__ --expt-relaxed-constexpr -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=gridding -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_75,code=compute_75 -gencode=arch=compute_75,code=sm_75
FAILED: C:/Repos/PoinTr-master/extensions/gridding/build/temp.win-amd64-3.9/Release/gridding_reverse.obj
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin\nvcc --generate-dependencies-with-compile --dependency-output C:\Repos\PoinTr-master\extensions\gridding\build\temp.win-amd64-3.9\Release\gridding_reverse.obj.d --use-local-env
-Xcompiler /MD -Xcompiler /wd4819 -Xcompiler /wd4251 -Xcompiler /wd4244 -Xcompiler /wd4267 -Xcompiler /wd4275 -Xcompiler /wd4018 -Xcompiler /wd4190 -Xcompiler /EHsc -Xcudafe --diag_suppress=base_class_has_different_dll_interface -Xcudaf
e --diag_suppress=field_without_dll_interface -Xcudafe --diag_suppress=dll_interface_conflict_none_assumed -Xcudafe --diag_suppress=dll_interface_conflict_dllexport_assumed -IC:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site
-packages\torch\include -IC:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\include\torch\csrc\api\include -IC:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\include\TH -IC:\Users
peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\include\THC "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\include" -IC:\Users\peter\AppData\Local\Programs\Python\Python39\include -IC:\Users\peter\AppDat
a\Local\Programs\Python\Python39\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.2933
3\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x
86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" -c C:\Repos\PoinTr-master\extensions\gridding\gri
dding_reverse.cu -o C:\Repos\PoinTr-master\extensions\gridding\build\temp.win-amd64-3.9\Release\gridding_reverse.obj -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATO
RS__ --expt-relaxed-constexpr -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=gridding -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_75,code=compute_75 -gencode=arch=compute_75,code=sm_75
C:/Repos/PoinTr-master/extensions/gridding/gridding_reverse.cu(9): fatal error C1083: Impossible d'ouvrir le fichier includeá: 'bits/stdc++.h'á: No such file or directory
gridding_reverse.cu
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 1717, in _run_ninja_build
subprocess.run(
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Repos\PoinTr-master\extensions\gridding\setup.py", line 11, in
setup(name='gridding',
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools_init_.py", line 153, in setup
return distutils.core.setup(**attrs)
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\install.py", line 67, in run
self.do_egg_install()
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\install.py", line 109, in do_egg_install
self.run_command('bdist_egg')
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\bdist_egg.py", line 164, in run
cmd = self.call_command('install_lib', warn_dir=0)
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\bdist_egg.py", line 150, in call_command
self.run_command(cmdname)
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\install_lib.py", line 11, in run
self.build()
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\distutils\command\install_lib.py", line 107, in build
self.run_command('build_ext')
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\build_ext.py", line 79, in run
_build_ext.run(self)
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\Cython\Distutils\old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\distutils\command\build_ext.py", line 340, in run
self.build_extensions()
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 735, in build_extensions
build_ext.build_extensions(self)
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\Cython\Distutils\old_build_ext.py", line 195, in build_extensions
_build_ext.build_ext.build_extensions(self)
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\distutils\command\build_ext.py", line 449, in build_extensions
self._build_extensions_serial()
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\distutils\command\build_ext.py", line 474, in _build_extensions_serial
self.build_extension(ext)
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\build_ext.py", line 196, in build_extension
_build_ext.build_extension(self, ext)
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\distutils\command\build_ext.py", line 529, in build_extension
objects = self.compiler.compile(sources,
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 708, in win_wrap_ninja_compile
_write_ninja_file_and_compile_objects(
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 1399, in _write_ninja_file_and_compile_objects
_run_ninja_build(
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 1733, in _run_ninja_build
raise RuntimeError(message) from e
RuntimeError: Error compiling objects for extension`

Could this error be related to my previous error ?

Thank you for your help (:

@yuxumin
Copy link
Owner

yuxumin commented Dec 5, 2021

@LeiKeRrr , these two errors, in my opinion, are related. I think the error comes from the cuda. However, i am not familiar with Pytorch in Windows. Sorry for no helpful solutions i can provide. ):

@LeiKeRrr
Copy link
Author

LeiKeRrr commented Dec 5, 2021

Ok no problem (:

I'll work on it and close this issue if I succeed.

@blukaz
Copy link

blukaz commented Dec 9, 2021

@LeiKeRrr Hi, I tested this repo in several environments (windows, ubuntu and colab). For your case I can for sure underline what @yuxumin said and that is that you have a missmatch between versions of pytorch and windows. For example, I had a similar issue under windows, even though the versions "matched" (I thought they match). The problem with windows is that you may have some newer cuda toolkit version due to some updates and you haven't realized that.
I would suggest that you go under Settings→Apps and search for "cuda" if you find more than one version installed then this should be the issue.
I hope this helps.
Cheers!

@LeiKeRrr
Copy link
Author

Hi @blukaz !

Thank you for your help. I searched for another cuda version in my Apps window but unfortunately there are only CUDA 10.2 applications as you can see below :

image

Also, you can see on the following image some packages that are installed in my virtual environment :

image

I just remembered that when installing the required extensions, I could not install version 0.9 of open3D because I use Python 3.9. So I have another version of open3D. Could this be related to my problem?

Thank you in advance for your help !

@blukaz
Copy link

blukaz commented Dec 13, 2021

@LeiKeRrr Actually, the problem lies in knn_cuda. The implementation from here is not compatible with Windows platforms. I've fixed those issues which you can find here.
I hope this will help!

@LeiKeRrr
Copy link
Author

Hi !

Thank you so much, it worked !

However now I have a new error but I'll work on it and make a new issue if necessary.

Thanks all !

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

No branches or pull requests

3 participants