unlimblue / KNN_CUDA

pytorch knn [cuda version]
292 stars 37 forks source link

Unable to import KNN #6

Closed shashidhar100 closed 3 years ago

shashidhar100 commented 3 years ago

windows when i try to do import from knn_cuda import KNN i get following error

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)) INFO: Could not find files for the given pattern(s). Traceback (most recent call last): File "", line 1, in File "G:\python library environments\torch\lib\site-packages\knn_cuda__init.py", line 38, in _knn = load_cpp_ext("knn") File "G:\python library environments\torch\lib\site-packages\knn_cuda\init__.py", line 26, in load_cpp_ext ext = load( File "G:\python library environments\torch\lib\site-packages\torch\utils\cpp_extension.py", line 986, in load return _jit_compile( File "G:\python library environments\torch\lib\site-packages\torch\utils\cpp_extension.py", line 1193, in _jit_compile _write_ninja_file_and_build_library( File "G:\python library environments\torch\lib\site-packages\torch\utils\cpp_extension.py", line 1285, in _write_ninja_file_and_build_library _write_ninja_file_to_build_library( File "G:\python library environments\torch\lib\site-packages\torch\utils\cpp_extension.py", line 1679, in _write_ninja_file_to_build_library _write_ninja_file( File "G:\python library environments\torch\lib\site-packages\torch\utils\cpp_extension.py", line 1790, in _write_ninja_file cl_paths = subprocess.check_output(['where', File "c:\users\shash\appdata\local\programs\python\python38\lib\subprocess.py", line 411, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "c:\users\shash\appdata\local\programs\python\python38\lib\subprocess.py", line 512, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['where', 'cl']' returned non-zero exit status 1.

JotaCe7 commented 3 years ago

Hi. For this to work you have to make sure that cl command can be called from your prompt. This and this shows solutions for windows 10. But the easiest workaround I found is just add cl.exe dir path to the environmental variables. Default path is "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\bin...". choose the right one accordingly to your architecture.

shashidhar100 commented 3 years ago

Thank you for the solution but now i'm getting this problem Traceback (most recent call last): File "", line 1, in File "/home/cvg-ws2/miniconda3/envs/torchenv/lib/python3.8/site-packages/knn_cuda/init.py", line 38, in _knn = load_cpp_ext("knn") File "/home/cvg-ws2/miniconda3/envs/torchenv/lib/python3.8/site-packages/knn_cuda/init.py", line 26, in load_cpp_ext ext = load( File "/home/cvg-ws2/miniconda3/envs/torchenv/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 986, in load return _jit_compile( File "/home/cvg-ws2/miniconda3/envs/torchenv/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1213, in _jit_compile return _import_module_from_library(name, build_directory, is_python_module) File "/home/cvg-ws2/miniconda3/envs/torchenv/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1560, in _import_module_from_library file, path, description = imp.find_module(module_name, [path]) File "/home/cvg-ws2/miniconda3/envs/torchenv/lib/python3.8/imp.py", line 296, in find_module raise ImportError(_ERR_MSG.format(name), name=name) ImportError: No module named 'knn'

zcxxlshirley commented 3 years ago

Thank you for the solution but now i'm getting this problem Traceback (most recent call last): File "", line 1, in File "/home/cvg-ws2/miniconda3/envs/torchenv/lib/python3.8/site-packages/knn_cuda/init.py", line 38, in _knn = load_cpp_ext("knn") File "/home/cvg-ws2/miniconda3/envs/torchenv/lib/python3.8/site-packages/knn_cuda/init.py", line 26, in load_cpp_ext ext = load( File "/home/cvg-ws2/miniconda3/envs/torchenv/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 986, in load return _jit_compile( File "/home/cvg-ws2/miniconda3/envs/torchenv/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1213, in _jit_compile return _import_module_from_library(name, build_directory, is_python_module) File "/home/cvg-ws2/miniconda3/envs/torchenv/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1560, in _import_module_from_library file, path, description = imp.find_module(module_name, [path]) File "/home/cvg-ws2/miniconda3/envs/torchenv/lib/python3.8/imp.py", line 296, in find_module raise ImportError(_ERR_MSG.format(name), name=name) ImportError: No module named 'knn'

have U solved this problem? I meet it too,checked a lot from the Internet ,but found no answer. how do you solve it?

shashidhar100 commented 3 years ago

No, But I wrote the KNN in pytorch to run it on the gpu

def knn(pc,n_neighbors=32):  
    dist = torch.cdist(pc,pc) 
    neigbhors = dist.topk(k=n_neighbors,dim=2,largest=False) 
    return neigbhors.indices