nmslib / hnswlib

Header-only C++/python library for fast approximate nearest neighbors
https://github.com/nmslib/hnswlib
Apache License 2.0
4.12k stars 609 forks source link

Could not build wheels for hnswlib, which is required to install pyproject.toml-based projects #504

Closed fislysandi closed 10 months ago

fislysandi commented 10 months ago

OS: WindowsTerminal_2TNmMHpJQg

dump ` Building wheel for hnswlib (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for hnswlib (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [165 lines of output] running bdist_wheel running build running build_ext creating tmp x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include/python3.10 -c /tmp/tmpgmylipmn.cpp -o tmp/tmpgmylipmn.o -std=c++14 x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include/python3.10 -c /tmp/tmp5jtwvm1i.cpp -o tmp/tmp5jtwvm1i.o -fvisibility=hidden creating build creating build/temp.linux-x86_64-3.10 creating build/temp.linux-x86_64-3.10/python_bindings x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/tmp/pip-build-env-_ahgfr6b/overlay/local/lib/python3.10/dist-packages/pybind11/include -I/tmp/pip-build-env-_ahgfr6b/overlay/local/lib/python3.10/dist-packages/numpy/core/include -I./hnswlib/ -I/usr/include/python3.10 -c ./python_bindings/bindings.cpp -o build/temp.linux-x86_64-3.10/./python_bindings/bindings.o -O3 -fopenmp -DVERSION_INFO=\"0.7.0\" -std=c++14 -fvisibility=hidden ./python_bindings/bindings.cpp: In function ‘void get_input_array_shapes(const pybind11::buffer_info&, size_t, size_t)’: ./python_bindings/bindings.cpp:101:67: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long int’ [-Wformat=] 101 "Input vector data wrong shape. Number of dimensions %d. Data must be a 1D or 2D array.", ~^
int
%ld
102 buffer.ndim);
~~~
long int
  ./python_bindings/bindings.cpp: In function ‘std::vector<long unsigned int> get_input_ids_and_check_shapes(const pybind11::object&, size_t)’:
  ./python_bindings/bindings.cpp:121:58: warning: comparison of integer expressions of different signedness: ‘__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
    121 |         if (!((ids_numpy.ndim == 1 && ids_numpy.shape[0] == feature_rows) ||
  ./python_bindings/bindings.cpp:125:41: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘pybind11::ssize_t’ {aka ‘long int’} [-Wformat=]
    125 |                 "The input label shape %d does not match the input data vector shape %d",
        |                                        ~^
        |                                         |
        |                                         int
        |                                        %ld
    126 |                 ids_numpy.ndim, feature_rows);
        |                 ~~~~~~~~~~~~~~
        |                           |
        |                           pybind11::ssize_t {aka long int}
  ./python_bindings/bindings.cpp:125:87: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
    125 |                 "The input label shape %d does not match the input data vector shape %d",
        |                                                                                      ~^
        |                                                                                       |
        |                                                                                       int
        |                                                                                      %ld
    126 |                 ids_numpy.ndim, feature_rows);
        |                                 ~~~~~~~~~~~~
        |                                 |
        |                                 size_t {aka long unsigned int}
  In file included from /tmp/pip-build-env-_ahgfr6b/overlay/local/lib/python3.10/dist-packages/pybind11/include/pybind11/detail/../attr.h:13,
                   from /tmp/pip-build-env-_ahgfr6b/overlay/local/lib/python3.10/dist-packages/pybind11/include/pybind11/detail/class.h:12,
                   from /tmp/pip-build-env-_ahgfr6b/overlay/local/lib/python3.10/dist-packages/pybind11/include/pybind11/pybind11.h:13,
                   from /tmp/pip-build-env-_ahgfr6b/overlay/local/lib/python3.10/dist-packages/pybind11/include/pybind11/functional.h:12,
                   from ./python_bindings/bindings.cpp:2:
  ./python_bindings/bindings.cpp: In function ‘PyObject* PyInit_hnswlib()’:
  /tmp/pip-build-env-_ahgfr6b/overlay/local/lib/python3.10/dist-packages/pybind11/include/pybind11/detail/../detail/common.h:428:33: warning: ‘PyObject* pybind11_init()’ is deprecated: PYBIND11_PLUGIN is deprecated, use PYBIND11_MODULE [-Wdeprecated-declarations]
    428 |             return pybind11_init();                                                               \
        |                    ~~~~~~~~~~~~~^~
  ./python_bindings/bindings.cpp:876:1: note: in expansion of macro ‘PYBIND11_PLUGIN’
    876 | PYBIND11_PLUGIN(hnswlib) {
        | ^~~~~~~~~~~~~~~
  /tmp/pip-build-env-_ahgfr6b/overlay/local/lib/python3.10/dist-packages/pybind11/include/pybind11/detail/../detail/common.h:423:22: note: declared here
    423 |     static PyObject *pybind11_init();                                                             \
        |                      ^~~~~~~~~~~~~
  ./python_bindings/bindings.cpp:876:1: note: in expansion of macro ‘PYBIND11_PLUGIN’
    876 | PYBIND11_PLUGIN(hnswlib) {
        | ^~~~~~~~~~~~~~~
  ./python_bindings/bindings.cpp: In function ‘PyObject* pybind11_init()’:
  ./python_bindings/bindings.cpp:877:31: warning: ‘pybind11::module_::module_(const char*, const char*)’ is deprecated: Use PYBIND11_MODULE or module_::create_extension_module instead [-Wdeprecated-declarations]
    877 |         py::module m("hnswlib");
        |                               ^
  In file included from /tmp/pip-build-env-_ahgfr6b/overlay/local/lib/python3.10/dist-packages/pybind11/include/pybind11/functional.h:12,
                   from ./python_bindings/bindings.cpp:2:
  /tmp/pip-build-env-_ahgfr6b/overlay/local/lib/python3.10/dist-packages/pybind11/include/pybind11/pybind11.h:1159:14: note: declared here
   1159 |     explicit module_(const char *name, const char *doc = nullptr) {
        |              ^~~~~~~
  ./python_bindings/bindings.cpp: In instantiation of ‘pybind11::object Index<dist_t, data_t>::knnQuery_return_numpy(pybind11::object, size_t, int, const std::function<bool(long unsigned int)>&) [with dist_t = float; data_t = float; size_t = long unsigned int]’:
  ./python_bindings/bindings.cpp:892:28:   required from here
  ./python_bindings/bindings.cpp:619:22: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
    619 |             if (rows <= num_threads * 4) {
        |                 ~~~~~^~~~~~~~~~~~~~~~~~
  ./python_bindings/bindings.cpp:647:28: warning: unused variable ‘data’ [-Wunused-variable]
    647 |                     float* data = (float*)items.data(row);
        |                            ^~~~
  ./python_bindings/bindings.cpp:667:22: warning: deleting ‘void*’ is undefined [-Wdelete-incomplete]
    667 |             delete[] f;
        |                      ^
  ./python_bindings/bindings.cpp:670:22: warning: deleting ‘void*’ is undefined [-Wdelete-incomplete]
    670 |             delete[] f;
        |                      ^
  ./python_bindings/bindings.cpp: In instantiation of ‘void Index<dist_t, data_t>::addItems(pybind11::object, pybind11::object, int, bool) [with dist_t = float; data_t = float]’:
  ./python_bindings/bindings.cpp:898:28:   required from here
  ./python_bindings/bindings.cpp:257:22: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
    257 |         if (features != dim)
        |             ~~~~~~~~~^~~~~~
  ./python_bindings/bindings.cpp:261:18: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
    261 |         if (rows <= num_threads * 4) {
        |             ~~~~~^~~~~~~~~~~~~~~~~~
  ./python_bindings/bindings.cpp: In instantiation of ‘pybind11::object BFIndex<dist_t, data_t>::knnQuery_return_numpy(pybind11::object, size_t, const std::function<bool(long unsigned int)>&) [with dist_t = float; data_t = float; size_t = long unsigned int]’:
  ./python_bindings/bindings.cpp:960:44:   required from here
  ./python_bindings/bindings.cpp:853:22: warning: deleting ‘void*’ is undefined [-Wdelete-incomplete]
    853 |             delete[] f;
        |                      ^
  ./python_bindings/bindings.cpp:856:22: warning: deleting ‘void*’ is undefined [-Wdelete-incomplete]
    856 |             delete[] f;
        |                      ^
  ./python_bindings/bindings.cpp: In instantiation of ‘void BFIndex<dist_t, data_t>::addItems(pybind11::object, pybind11::object) [with dist_t = float; data_t = float]’:
  ./python_bindings/bindings.cpp:961:44:   required from here
  ./python_bindings/bindings.cpp:778:22: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
    778 |         if (features != dim)
        |             ~~~~~~~~~^~~~~~
  In file included from ./hnswlib/hnswlib.h:199,
                   from ./python_bindings/bindings.cpp:6:
  ./hnswlib/hnswalg.h: In instantiation of ‘hnswlib::HierarchicalNSW<dist_t>::HierarchicalNSW(hnswlib::SpaceInterface<dist_t>*, size_t, size_t, size_t, size_t, bool) [with dist_t = float; size_t = long unsigned int]’:
  ./python_bindings/bindings.cpp:488:35:   required from ‘static Index<float>* Index<dist_t, data_t>::createFromParams(pybind11::dict) [with dist_t = float; data_t = float]’
  ./python_bindings/bindings.cpp:880:38:   required from here
  ./hnswlib/hnswalg.h:42:29: warning: ‘hnswlib::HierarchicalNSW<float>::link_list_locks_’ will be initialized after [-Wreorder]
     42 |     std::vector<std::mutex> link_list_locks_;
        |                             ^~~~~~~~~~~~~~~~
  ./hnswlib/hnswalg.h:39:37: warning:   ‘std::vector<std::mutex> hnswlib::HierarchicalNSW<float>::label_op_locks_’ [-Wreorder]
     39 |     mutable std::vector<std::mutex> label_op_locks_;
        |                                     ^~~~~~~~~~~~~~~
  ./hnswlib/hnswalg.h:88:5: warning:   when initialized here [-Wreorder]
     88 |     HierarchicalNSW(
        |     ^~~~~~~~~~~~~~~
  In file included from ./hnswlib/hnswlib.h:199,
                   from ./python_bindings/bindings.cpp:6:
  ./hnswlib/hnswalg.h: In instantiation of ‘std::vector<data_t> hnswlib::HierarchicalNSW<dist_t>::getDataByLabel(hnswlib::labeltype) const [with data_t = float; dist_t = float; hnswlib::labeltype = long unsigned int]’:
  ./python_bindings/bindings.cpp:323:69:   required from ‘std::vector<std::vector<data_t> > Index<dist_t, data_t>::getDataReturnList(pybind11::object) [with dist_t = float; data_t = float]’
  ./python_bindings/bindings.cpp:903:49:   required from here
  ./hnswlib/hnswalg.h:755:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
    755 |         for (int i = 0; i < dim; i++) {
        |                         ~~^~~~~
  ./python_bindings/bindings.cpp: In instantiation of ‘pybind11::dict Index<dist_t, data_t>::getAnnData() const [with dist_t = float; data_t = float]’:
  ./python_bindings/bindings.cpp:467:27:   required from ‘pybind11::dict Index<dist_t, data_t>::getIndexParams() const [with dist_t = float; data_t = float]’
  ./python_bindings/bindings.cpp:945:57:   required from here
  ./python_bindings/bindings.cpp:383:22: warning: deleting ‘void*’ is undefined [-Wdelete-incomplete]
    383 |             delete[] f;
        |                      ^
  ./python_bindings/bindings.cpp:386:22: warning: deleting ‘void*’ is undefined [-Wdelete-incomplete]
    386 |             delete[] f;
        |                      ^
  ./python_bindings/bindings.cpp:389:22: warning: deleting ‘void*’ is undefined [-Wdelete-incomplete]
    389 |             delete[] f;
        |                      ^
  ./python_bindings/bindings.cpp:392:22: warning: deleting ‘void*’ is undefined [-Wdelete-incomplete]
    392 |             delete[] f;
        |                      ^
  ./python_bindings/bindings.cpp:395:22: warning: deleting ‘void*’ is undefined [-Wdelete-incomplete]
    395 |             delete[] f;
        |                      ^
  In file included from ./hnswlib/hnswlib.h:198,
                   from ./python_bindings/bindings.cpp:6:
  ./hnswlib/bruteforce.h: In instantiation of ‘std::priority_queue<std::pair<dist_t, long unsigned int> > hnswlib::BruteforceSearch<dist_t>::searchKnn(const void*, size_t, hnswlib::BaseFilterFunctor*) const [with dist_t = float; typename std::vector<std::pair<dist_t, long unsigned int>, std::allocator<std::pair<dist_t, long unsigned int> > >::value_type = std::pair<float, long unsigned int>; size_t = long unsigned int]’:
  ./python_bindings/bindings.cpp:841:100:   required from ‘pybind11::object BFIndex<dist_t, data_t>::knnQuery_return_numpy(pybind11::object, size_t, const std::function<bool(long unsigned int)>&) [with dist_t = float; data_t = float; size_t = long unsigned int]’
  ./python_bindings/bindings.cpp:960:44:   required from here
  ./hnswlib/bruteforce.h:105:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
    105 |         for (int i = 0; i < k; i++) {
        |                         ~~^~~
  ./hnswlib/bruteforce.h:113:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘const size_t’ {aka ‘const long unsigned int’} [-Wsign-compare]
    113 |         for (int i = k; i < cur_element_count; i++) {
        |                         ~~^~~~~~~~~~~~~~~~~~~
  In file included from ./python_bindings/bindings.cpp:6:
  ./hnswlib/hnswlib.h: At global scope:
  ./hnswlib/hnswlib.h:80:13: warning: ‘bool AVX512Capable()’ defined but not used [-Wunused-function]
     80 | static bool AVX512Capable() {
        |             ^~~~~~~~~~~~~
  x86_64-linux-gnu-gcc: fatal error: Killed signal terminated program cc1plus
  compilation terminated.
  error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
  [end of output]

`

fislysandi commented 10 months ago

SOLVED by Doing Apt install python3-hnswlib.

now it built successfully