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

Python 3.10. clang flag gives error #196

Open
KorayUlusan opened this issue Jun 7, 2023 · 2 comments
Open

Python 3.10. clang flag gives error #196

KorayUlusan opened this issue Jun 7, 2023 · 2 comments
Labels
next release All the issues, PRs that are targeted to be the part of next release of the package.

Comments

@KorayUlusan
Copy link

Installation with pip doesn't work: I'm using a apple M1 chip and clang gives an error.

# running
python3.10 -m pip install imagededup
#gives this error
clang: error: the clang compiler does not support '-march=native'

It's working on python3.11. Is it possible to update the old version?


The complete output

python3.10 -m pip install imagededup
Collecting imagededup
  Using cached imagededup-0.3.1.tar.gz (20.3 MB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: torch in /opt/homebrew/lib/python3.10/site-packages (from imagededup) (2.0.0)
Requirement already satisfied: torchvision in /opt/homebrew/lib/python3.10/site-packages (from imagededup) (0.15.1)
Requirement already satisfied: Pillow>=9.0 in /opt/homebrew/lib/python3.10/site-packages (from imagededup) (9.2.0)
Requirement already satisfied: tqdm in /opt/homebrew/lib/python3.10/site-packages (from imagededup) (4.64.1)
Collecting scikit-learn (from imagededup)
  Using cached scikit_learn-1.2.2-cp310-cp310-macosx_12_0_arm64.whl (8.5 MB)
Collecting PyWavelets (from imagededup)
  Using cached PyWavelets-1.4.1-cp310-cp310-macosx_11_0_arm64.whl (4.3 MB)
Requirement already satisfied: matplotlib in /opt/homebrew/lib/python3.10/site-packages (from imagededup) (3.6.2)
Requirement already satisfied: contourpy>=1.0.1 in /opt/homebrew/lib/python3.10/site-packages (from matplotlib->imagededup) (1.0.5)
Requirement already satisfied: cycler>=0.10 in /opt/homebrew/lib/python3.10/site-packages (from matplotlib->imagededup) (0.11.0)
Requirement already satisfied: fonttools>=4.22.0 in /opt/homebrew/lib/python3.10/site-packages (from matplotlib->imagededup) (4.37.4)
Requirement already satisfied: kiwisolver>=1.0.1 in /opt/homebrew/lib/python3.10/site-packages (from matplotlib->imagededup) (1.4.4)
Requirement already satisfied: numpy>=1.19 in /opt/homebrew/lib/python3.10/site-packages (from matplotlib->imagededup) (1.23.3)
Requirement already satisfied: packaging>=20.0 in /opt/homebrew/lib/python3.10/site-packages (from matplotlib->imagededup) (21.3)
Requirement already satisfied: pyparsing>=2.2.1 in /opt/homebrew/lib/python3.10/site-packages (from matplotlib->imagededup) (3.0.9)
Requirement already satisfied: python-dateutil>=2.7 in /Users/koray/Library/Python/3.10/lib/python/site-packages (from matplotlib->imagededup) (2.8.2)
Requirement already satisfied: scipy>=1.3.2 in /opt/homebrew/lib/python3.10/site-packages (from scikit-learn->imagededup) (1.9.3)
Collecting joblib>=1.1.1 (from scikit-learn->imagededup)
  Using cached joblib-1.2.0-py3-none-any.whl (297 kB)
Collecting threadpoolctl>=2.0.0 (from scikit-learn->imagededup)
  Using cached threadpoolctl-3.1.0-py3-none-any.whl (14 kB)
Requirement already satisfied: filelock in /opt/homebrew/lib/python3.10/site-packages (from torch->imagededup) (3.8.0)
Requirement already satisfied: typing-extensions in /opt/homebrew/lib/python3.10/site-packages (from torch->imagededup) (4.5.0)
Requirement already satisfied: sympy in /opt/homebrew/lib/python3.10/site-packages (from torch->imagededup) (1.11.1)
Requirement already satisfied: networkx in /opt/homebrew/lib/python3.10/site-packages (from torch->imagededup) (3.1)
Requirement already satisfied: jinja2 in /Users/koray/Library/Python/3.10/lib/python/site-packages (from torch->imagededup) (3.1.2)
Requirement already satisfied: requests in /opt/homebrew/lib/python3.10/site-packages (from torchvision->imagededup) (2.28.1)
Requirement already satisfied: six>=1.5 in /opt/homebrew/lib/python3.10/site-packages (from python-dateutil>=2.7->matplotlib->imagededup) (1.16.0)
Requirement already satisfied: MarkupSafe>=2.0 in /Users/koray/Library/Python/3.10/lib/python/site-packages (from jinja2->torch->imagededup) (2.1.1)
Requirement already satisfied: charset-normalizer<3,>=2 in /opt/homebrew/lib/python3.10/site-packages (from requests->torchvision->imagededup) (2.1.0)
Requirement already satisfied: idna<4,>=2.5 in /opt/homebrew/lib/python3.10/site-packages (from requests->torchvision->imagededup) (3.3)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /opt/homebrew/lib/python3.10/site-packages (from requests->torchvision->imagededup) (1.26.11)
Requirement already satisfied: certifi>=2017.4.17 in /opt/homebrew/lib/python3.10/site-packages (from requests->torchvision->imagededup) (2022.6.15)
Requirement already satisfied: mpmath>=0.19 in /opt/homebrew/lib/python3.10/site-packages (from sympy->torch->imagededup) (1.2.1)
Building wheels for collected packages: imagededup
  Building wheel for imagededup (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [44 lines of output]
      /opt/homebrew/lib/python3.10/site-packages/setuptools/dist.py:788: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
        warnings.warn(
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-12-arm64-cpython-310
      creating build/lib.macosx-12-arm64-cpython-310/imagededup
      copying imagededup/__init__.py -> build/lib.macosx-12-arm64-cpython-310/imagededup
      creating build/lib.macosx-12-arm64-cpython-310/imagededup/methods
      copying imagededup/methods/__init__.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/methods
      copying imagededup/methods/cnn.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/methods
      copying imagededup/methods/hashing.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/methods
      creating build/lib.macosx-12-arm64-cpython-310/imagededup/utils
      copying imagededup/utils/general_utils.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/utils
      copying imagededup/utils/image_utils.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/utils
      copying imagededup/utils/__init__.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/utils
      copying imagededup/utils/logger.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/utils
      copying imagededup/utils/plotter.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/utils
      copying imagededup/utils/data_generator.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/utils
      creating build/lib.macosx-12-arm64-cpython-310/imagededup/evaluation
      copying imagededup/evaluation/evaluation.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/evaluation
      copying imagededup/evaluation/__init__.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/evaluation
      creating build/lib.macosx-12-arm64-cpython-310/imagededup/handlers
      copying imagededup/handlers/__init__.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/handlers
      creating build/lib.macosx-12-arm64-cpython-310/imagededup/handlers/metrics
      copying imagededup/handlers/metrics/information_retrieval.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/handlers/metrics
      copying imagededup/handlers/metrics/classification.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/handlers/metrics
      copying imagededup/handlers/metrics/__init__.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/handlers/metrics
      creating build/lib.macosx-12-arm64-cpython-310/imagededup/handlers/search
      copying imagededup/handlers/search/bktree.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/handlers/search
      copying imagededup/handlers/search/__init__.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/handlers/search
      copying imagededup/handlers/search/brute_force_cython.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/handlers/search
      copying imagededup/handlers/search/brute_force.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/handlers/search
      copying imagededup/handlers/search/retrieval.py -> build/lib.macosx-12-arm64-cpython-310/imagededup/handlers/search
      running build_ext
      building 'brute_force_cython_ext' extension
      creating build/temp.macosx-12-arm64-cpython-310
      creating build/temp.macosx-12-arm64-cpython-310/imagededup
      creating build/temp.macosx-12-arm64-cpython-310/imagededup/handlers
      creating build/temp.macosx-12-arm64-cpython-310/imagededup/handlers/search
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -Iimagededup/handlers/search -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c imagededup/handlers/search/brute_force_cython_ext.cpp -o build/temp.macosx-12-arm64-cpython-310/imagededup/handlers/search/brute_force_cython_ext.o -O3 -march=native -mtune=native -stdlib=libc++
      clang: error: the clang compiler does not support '-march=native'
      error: command '/usr/bin/clang' 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 imagededup
  Running setup.py clean for imagededup
Failed to build imagededup
ERROR: Could not build wheels for imagededup, which is required to install pyproject.toml-based projects
@tanujjain
Copy link
Collaborator

Tested it on M1 max and it works. Don't have quick access to M1 unfortunately.

Meanwhile, just using the space to collect resources for the fix:

  1. https://stackoverflow.com/questions/65966969/why-does-march-native-not-work-on-apple-m1
  2. A solution to build Apple Silicon (M1) Python binary wheels grpc/grpc#29262
  3. BLD: fail to build on Apple M1 numpy/numpy#17807

@tanujjain tanujjain added the next release All the issues, PRs that are targeted to be the part of next release of the package. label Jul 28, 2023
@bonlime
Copy link

bonlime commented Sep 29, 2023

I encountered the same issue. my clang version seems to be too old to support -march=native flag:

❯ clang --version
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: arm64-apple-darwin21.6.0

Fixed the problem by commenting out the -march=native in setup.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next release All the issues, PRs that are targeted to be the part of next release of the package.
Projects
None yet
Development

No branches or pull requests

3 participants