teddykoker / torchsort

Fast, differentiable sorting and ranking in PyTorch
https://pypi.org/project/torchsort/
Apache License 2.0
765 stars 33 forks source link

conda install torchsort error #68

Closed IMTRL closed 1 year ago

IMTRL commented 1 year ago

Hello,I have run the command according to the steps of conda installing torchsort in the introduction, but there will still be an error when I execute the install command at the end. Could you please tell me how to solve it? Thank you for your help.

error:


  Preparing metadata (setup.py) ... done
  Building wheels for collected packages: torchsort
  Building wheel for torchsort (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [45 lines of output]
      running bdist_wheel
      /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/utils/cpp_extension.py:476: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend.
        warnings.warn(msg.format('we could not find ninja.'))
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-38
      creating build/lib.linux-x86_64-cpython-38/torchsort
      copying torchsort/__init__.py -> build/lib.linux-x86_64-cpython-38/torchsort
      copying torchsort/ops.py -> build/lib.linux-x86_64-cpython-38/torchsort
      running egg_info
      writing torchsort.egg-info/PKG-INFO
      writing dependency_links to torchsort.egg-info/dependency_links.txt
      writing requirements to torchsort.egg-info/requires.txt
      writing top-level names to torchsort.egg-info/top_level.txt
      reading manifest file 'torchsort.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      writing manifest file 'torchsort.egg-info/SOURCES.txt'
      copying torchsort/isotonic_cpu.cpp -> build/lib.linux-x86_64-cpython-38/torchsort
      copying torchsort/isotonic_cuda.cu -> build/lib.linux-x86_64-cpython-38/torchsort
      running build_ext
      building 'torchsort.isotonic_cpu' extension
      creating build/temp.linux-x86_64-cpython-38
      creating build/temp.linux-x86_64-cpython-38/torchsort
      /home/guest/anaconda3/envs/tanruilei/bin/x86_64-conda-linux-gnu-cc -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -Wstrict-prototypes -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/guest/anaconda3/envs/tanruilei/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/guest/anaconda3/envs/tanruilei/include -fPIC -I/home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include -I/home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/TH -I/home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/THC -I/home/guest/anaconda3/envs/tanruilei/include/python3.8 -c torchsort/isotonic_cpu.cpp -o build/temp.linux-x86_64-cpython-38/torchsort/isotonic_cpu.o -fopenmp -ffast-math -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -DTORCH_EXTENSION_NAME=isotonic_cpu -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++17
      cc1plus: warning: command-line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
      In file included from /home/guest/anaconda3/envs/tanruilei/x86_64-conda-linux-gnu/include/c++/11.2.0/chrono:42,
                       from /home/guest/anaconda3/envs/tanruilei/x86_64-conda-linux-gnu/include/c++/11.2.0/mutex:39,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/c10/util/typeid.h:8,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/c10/core/ScalarTypeToTypeMeta.h:5,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/ATen/core/TensorBody.h:18,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/ATen/core/Tensor.h:3,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/ATen/Tensor.h:3,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/torch/csrc/autograd/function_hook.h:3,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/torch/csrc/autograd/cpp_hook.h:2,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/torch/csrc/autograd/variable.h:6,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/torch/csrc/autograd/autograd.h:3,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/autograd.h:3,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/all.h:7,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/torch/extension.h:4,
                       from torchsort/isotonic_cpu.cpp:32:
      /home/guest/anaconda3/envs/tanruilei/x86_64-conda-linux-gnu/include/c++/11.2.0/ctime:80:11: error: 'timespec_get' has not been declared in '::'
         80 |   using ::timespec_get;
            |           ^~~~~~~~~~~~
      error: command '/home/guest/anaconda3/envs/tanruilei/bin/x86_64-conda-linux-gnu-cc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for torchsort
  Running setup.py clean for torchsort
Failed to build torchsort
Installing collected packages: torchsort
  Running setup.py install for torchsort ... error
  error: subprocess-exited-with-error

  × Running setup.py install for torchsort did not run successfully.
  │ exit code: 1
  ╰─> [47 lines of output]
      running install
      /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-38
      creating build/lib.linux-x86_64-cpython-38/torchsort
      copying torchsort/__init__.py -> build/lib.linux-x86_64-cpython-38/torchsort
      copying torchsort/ops.py -> build/lib.linux-x86_64-cpython-38/torchsort
      running egg_info
      writing torchsort.egg-info/PKG-INFO
      writing dependency_links to torchsort.egg-info/dependency_links.txt
      writing requirements to torchsort.egg-info/requires.txt
      writing top-level names to torchsort.egg-info/top_level.txt
      /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/utils/cpp_extension.py:476: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend.
        warnings.warn(msg.format('we could not find ninja.'))
      reading manifest file 'torchsort.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      writing manifest file 'torchsort.egg-info/SOURCES.txt'
      copying torchsort/isotonic_cpu.cpp -> build/lib.linux-x86_64-cpython-38/torchsort
      copying torchsort/isotonic_cuda.cu -> build/lib.linux-x86_64-cpython-38/torchsort
      running build_ext
      building 'torchsort.isotonic_cpu' extension
      creating build/temp.linux-x86_64-cpython-38
      creating build/temp.linux-x86_64-cpython-38/torchsort
      /home/guest/anaconda3/envs/tanruilei/bin/x86_64-conda-linux-gnu-cc -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -Wstrict-prototypes -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/guest/anaconda3/envs/tanruilei/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/guest/anaconda3/envs/tanruilei/include -fPIC -I/home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include -I/home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/TH -I/home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/THC -I/home/guest/anaconda3/envs/tanruilei/include/python3.8 -c torchsort/isotonic_cpu.cpp -o build/temp.linux-x86_64-cpython-38/torchsort/isotonic_cpu.o -fopenmp -ffast-math -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -DTORCH_EXTENSION_NAME=isotonic_cpu -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++17
      cc1plus: warning: command-line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
      In file included from /home/guest/anaconda3/envs/tanruilei/x86_64-conda-linux-gnu/include/c++/11.2.0/chrono:42,
                       from /home/guest/anaconda3/envs/tanruilei/x86_64-conda-linux-gnu/include/c++/11.2.0/mutex:39,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/c10/util/typeid.h:8,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/c10/core/ScalarTypeToTypeMeta.h:5,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/ATen/core/TensorBody.h:18,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/ATen/core/Tensor.h:3,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/ATen/Tensor.h:3,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/torch/csrc/autograd/function_hook.h:3,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/torch/csrc/autograd/cpp_hook.h:2,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/torch/csrc/autograd/variable.h:6,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/torch/csrc/autograd/autograd.h:3,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/autograd.h:3,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/all.h:7,
                       from /home/guest/anaconda3/envs/tanruilei/lib/python3.8/site-packages/torch/include/torch/extension.h:4,
                       from torchsort/isotonic_cpu.cpp:32:
      /home/guest/anaconda3/envs/tanruilei/x86_64-conda-linux-gnu/include/c++/11.2.0/ctime:80:11: error: 'timespec_get' has not been declared in '::'
         80 |   using ::timespec_get;
            |           ^~~~~~~~~~~~
      error: command '/home/guest/anaconda3/envs/tanruilei/bin/x86_64-conda-linux-gnu-cc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> torchsort

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure 
IMTRL commented 1 year ago

And I have installed g++ using sudo apt install g++

teddykoker commented 1 year ago

See https://root-forum.cern.ch/t/error-timespec-get-has-not-been-declared-with-conda-root-package/45712. Maybe you need to install cmake through conda?

IMTRL commented 1 year ago

See https://root-forum.cern.ch/t/error-timespec-get-has-not-been-declared-with-conda-root-package/45712. Maybe you need to install cmake through conda?

Thank you for your reply. I have installed cmake and make, but the problem still exists. I will continue to inquire about the solutions that may be useful. Thank you very much

teddykoker commented 1 year ago

Could you try installing the CPP example extension here: https://github.com/pytorch/extension-cpp (in cpp/). It seems there may be an issue with your CPP environment unrelated to torchsort, so this would help verify.

IMTRL commented 1 year ago

you are right ! I need to learn how to build a correct CPP environment .

lfb-1 commented 1 year ago

@IMTRL Hey, very sorry to wake this old issue, but have you solved this problem? I encounter the same problem.

IMTRL commented 1 year ago

@IMTRL Hey, very sorry to wake this old issue, but have you solved this problem? I encounter the same problem.

yes,I miraculously solved this problem by recreating an anaconda environment and reinstalling it, but I am not sure why