Code Monkey home page Code Monkey logo

Comments (6)

SoroushMB avatar SoroushMB commented on July 18, 2024 3

I found the solution

I have a Mac Mini M1 and really needed the library to work for
So I searched a lot and finally find a proper solution for it.
You need to install Homebrew,Xcode,MacPorts
Then you need to install latest version of GCC which is compatible with arm64 architecture of M1 chipsets.
Therefore you need to type the following command in Terminal:
$ brew install gcc

It will start to install the latest version of GCC (which currently is GCC 11) on your system.
Then you need to found out that if it is correctly installed or not.
So:
$ port select --list gcc

When you enter it you will get an answer like the following one if your device didn't have any C++ compilers installed:

$ Available versions for gcc:
none (active)

It means that everything went well and your compiler is successfully installed.Now you can run article's commands in Terminal.
(Optional)If you wanted to know GCC's installation location on your disk just following command in Terminal:

$ which gcc

Hope that this comment help you all
@soroush.mbabaei is my instagram tag if you want to see more of my works

from ctcwordbeamsearch.

githubharald avatar githubharald commented on July 18, 2024 2

looks like the compiler uses some C++ stone age version in which you had to have a space between >> with nested C++ template (this is the error).
You somehow have to get your compiler using at least the C++11 (or even 14) standard. In setup.py you could try something like extra_compile_args=['-std=c++11'] or similar. Please google it how this has to look for your compiler.

from ctcwordbeamsearch.

githubharald avatar githubharald commented on July 18, 2024

Hi, hard to judge based on the output, and I also don't have an M1 available to test it.
It seems clang, the C++ compiler, failed. Can you check if you find some output where clang complains about the C++ code? Maybe there was a compilation error and this is why the whole pip installation fails.

from ctcwordbeamsearch.

Maisteru avatar Maisteru commented on July 18, 2024

Plenty of it (there is no code block so I attach it as raw data) :

(base) maisteru@Maisteru CTCWordBeamSearch % pip install .
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Processing /Users/maisteru/Documents/GitHub/CTCWordBeamSearch
Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy in /Users/maisteru/miniforge3/lib/python3.9/site-packages (from word-beam-search==1.0.1) (1.21.5)
Building wheels for collected packages: word-beam-search
Building wheel for word-beam-search (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [151 lines of output]
running bdist_wheel
running build
running build_ext
building 'word_beam_search' extension
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/maisteru/miniforge3/include -arch arm64 -fPIC -O2 -isystem /Users/maisteru/miniforge3/include -arch arm64 -Icpp/pybind/ -I/Users/maisteru/miniforge3/include/python3.9 -c cpp/Beam.cpp -o build/temp.macosx-11.0-arm64-3.9/cpp/Beam.o
In file included from cpp/Beam.cpp:1:
In file included from cpp/Beam.hpp:2:
cpp/HashFunction.hpp:14:14: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (const auto& l : text)
^
cpp/HashFunction.hpp:14:22: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (const auto& l : text)
^
In file included from cpp/Beam.cpp:1:
In file included from cpp/Beam.hpp:3:
In file included from cpp/LanguageModel.hpp:3:
cpp/PrefixTree.hpp:19:54: error: a space is required between consecutive right angle brackets (use '> >')
void addWords(const std::vector<std::vector<uint32_t>>& words);
^~
> >
cpp/PrefixTree.hpp:25:34: error: a space is required between consecutive right angle brackets (use '> >')
std::vector<std::vector<uint32_t>> getNextWords(const std::vector<uint32_t>& text) const;
^~
> >
cpp/PrefixTree.hpp:32:55: error: a space is required between consecutive right angle brackets (use '> >')
std::vector<std::pair<uint32_t, std::shared_ptr>> children;
^~
> >
cpp/PrefixTree.hpp:38:61: error: a space is required between consecutive right angle brackets (use '> >')
mutable std::map<uint32_t, std::vector<std::vector<uint32_t>>> m_level1Cache; // cache words of nodes in level 1
^~
> >
In file included from cpp/Beam.cpp:1:
In file included from cpp/Beam.hpp:3:
cpp/LanguageModel.hpp:14:6: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
enum class LanguageModelType
^
cpp/LanguageModel.hpp:36:34: error: a space is required between consecutive right angle brackets (use '> >')
std::vector<std::vector<uint32_t>> getNextWords(const std::vector<uint32_t>& text) const;
^~
> >
cpp/LanguageModel.hpp:52:16: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
size_t count = 0;
^
cpp/LanguageModel.hpp:53:15: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
double prob = 0.0;
^
cpp/LanguageModel.hpp:58:16: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
size_t count = 0;
^
cpp/LanguageModel.hpp:59:15: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
double prob = 0.0;
^
cpp/LanguageModel.hpp:65:16: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
double m_addK = 0.0; // add-k smoothing
^
In file included from cpp/Beam.cpp:1:
cpp/Beam.hpp:41:19: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
double m_prBlank = 1.0;
^
cpp/Beam.hpp:42:22: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
double m_prNonBlank = 0.0;
^
cpp/Beam.hpp:47:34: error: a space is required between consecutive right angle brackets (use '> >')
std::vector<std::vector<uint32_t>> m_wordHist; // history of words in text
^~
> >
cpp/Beam.hpp:48:23: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
double m_prTextTotal = 1.0;
^
cpp/Beam.hpp:49:30: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
double m_prTextUnnormalized = 1.0;
^
cpp/Beam.hpp:50:19: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
bool m_useNGrams = false;
^
cpp/Beam.hpp:51:23: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
bool m_forcastNGrams = false;
^
cpp/Beam.hpp:52:22: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
bool m_sampleNGrams = false;
^
cpp/Beam.hpp:56:52: error: a space is required between consecutive right angle brackets (use '> >')
std::pair<double, std::vector<std::vector<uint32_t>>> getNextWordsSampled(const std::shared_ptr& lm, const std::vector<uint32_t>& text) const;
^~
> >
cpp/Beam.hpp:68:34: error: a space is required between consecutive right angle brackets (use '> >')
std::vector<std::shared_ptr> getBestBeams(size_t beamWidth);
^~
> >
cpp/Beam.cpp:29:51: error: a space is required between consecutive right angle brackets (use '> >')
std::pair<double, std::vector<std::vector<uint32_t>>> Beam::getNextWordsSampled(const std::shared_ptr& lm, const std::vector<uint32_t>& text) const
^~
> >
cpp/Beam.cpp:32:2: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto nextWords=lm->getNextWords(text);
^
cpp/Beam.cpp:50:8: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
const auto& wordChars(newBeam->m_lm->getWordChars());
^
cpp/Beam.cpp:60:36: error: a space is required between consecutive right angle brackets (use '> >')
std::vector<std::vector<uint32_t>> nextWords;
^~
> >
cpp/Beam.cpp:62:9: error: no member named 'tie' in namespace 'std'
std::tie(sampleFactor, nextWords) = getNextWordsSampled(newBeam->m_lm, newBeam->m_wordDev);
~~~~~^
cpp/Beam.cpp:69:16: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (const auto& w : nextWords)
^
cpp/Beam.cpp:69:24: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (const auto& w : nextWords)
^
cpp/Beam.cpp:76:11: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
const auto& lastWord = newBeam->m_wordHist.back();
^
cpp/Beam.cpp:77:16: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (const auto& w : nextWords)
^
cpp/Beam.cpp:77:24: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (const auto& w : nextWords)
^
cpp/Beam.cpp:130:10: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
const auto& wordChars(newBeam->m_lm->getWordChars());
^
cpp/Beam.cpp:170:8: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
const auto nextWords=m_lm->getNextWords(m_wordDev);
^
cpp/Beam.cpp:176:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
const auto& completeWord = nextWords[0];
^
cpp/Beam.cpp:187:2: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto iter=m_beams.find(beam->getText());
^
cpp/Beam.cpp:199:33: error: a space is required between consecutive right angle brackets (use '> >')
std::vector<std::shared_ptr> BeamList::getBestBeams(size_t beamWidth)
^~
> >
cpp/Beam.cpp:202:63: error: a space is required between consecutive right angle brackets (use '> >')
typedef std::pair<std::vector<uint32_t>, std::shared_ptr> KeyValueType;
^~
> >
cpp/Beam.cpp:208:4: error: expected expression
,[](const KeyValueType& a, const KeyValueType& b) {return a.second->getTotalProb()*a.second->getTextualProb() > b.second->getTotalProb()*b.second->getTextualProb(); }
^
cpp/Beam.cpp:212:34: error: a space is required between consecutive right angle brackets (use '> >')
std::vector<std::shared_ptr> res;
^~
> >
26 warnings and 15 errors generated.
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 word-beam-search
Running setup.py clean for word-beam-search
Failed to build word-beam-search
Installing collected packages: word-beam-search
Running setup.py install for word-beam-search ... error
error: subprocess-exited-with-error

× Running setup.py install for word-beam-search did not run successfully.
│ exit code: 1
╰─> [156 lines of output]
running install
/Users/maisteru/miniforge3/lib/python3.9/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_ext
building 'word_beam_search' extension
creating build
creating build/temp.macosx-11.0-arm64-3.9
creating build/temp.macosx-11.0-arm64-3.9/cpp
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/maisteru/miniforge3/include -arch arm64 -fPIC -O2 -isystem /Users/maisteru/miniforge3/include -arch arm64 -Icpp/pybind/ -I/Users/maisteru/miniforge3/include/python3.9 -c cpp/Beam.cpp -o build/temp.macosx-11.0-arm64-3.9/cpp/Beam.o
In file included from cpp/Beam.cpp:1:
In file included from cpp/Beam.hpp:2:
cpp/HashFunction.hpp:14:14: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (const auto& l : text)
^
cpp/HashFunction.hpp:14:22: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (const auto& l : text)
^
In file included from cpp/Beam.cpp:1:
In file included from cpp/Beam.hpp:3:
In file included from cpp/LanguageModel.hpp:3:
cpp/PrefixTree.hpp:19:54: error: a space is required between consecutive right angle brackets (use '> >')
void addWords(const std::vector<std::vector<uint32_t>>& words);
^~
> >
cpp/PrefixTree.hpp:25:34: error: a space is required between consecutive right angle brackets (use '> >')
std::vector<std::vector<uint32_t>> getNextWords(const std::vector<uint32_t>& text) const;
^~
> >
cpp/PrefixTree.hpp:32:55: error: a space is required between consecutive right angle brackets (use '> >')
std::vector<std::pair<uint32_t, std::shared_ptr>> children;
^~
> >
cpp/PrefixTree.hpp:38:61: error: a space is required between consecutive right angle brackets (use '> >')
mutable std::map<uint32_t, std::vector<std::vector<uint32_t>>> m_level1Cache; // cache words of nodes in level 1
^~
> >
In file included from cpp/Beam.cpp:1:
In file included from cpp/Beam.hpp:3:
cpp/LanguageModel.hpp:14:6: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
enum class LanguageModelType
^
cpp/LanguageModel.hpp:36:34: error: a space is required between consecutive right angle brackets (use '> >')
std::vector<std::vector<uint32_t>> getNextWords(const std::vector<uint32_t>& text) const;
^~
> >
cpp/LanguageModel.hpp:52:16: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
size_t count = 0;
^
cpp/LanguageModel.hpp:53:15: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
double prob = 0.0;
^
cpp/LanguageModel.hpp:58:16: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
size_t count = 0;
^
cpp/LanguageModel.hpp:59:15: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
double prob = 0.0;
^
cpp/LanguageModel.hpp:65:16: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
double m_addK = 0.0; // add-k smoothing
^
In file included from cpp/Beam.cpp:1:
cpp/Beam.hpp:41:19: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
double m_prBlank = 1.0;
^
cpp/Beam.hpp:42:22: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
double m_prNonBlank = 0.0;
^
cpp/Beam.hpp:47:34: error: a space is required between consecutive right angle brackets (use '> >')
std::vector<std::vector<uint32_t>> m_wordHist; // history of words in text
^~
> >
cpp/Beam.hpp:48:23: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
double m_prTextTotal = 1.0;
^
cpp/Beam.hpp:49:30: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
double m_prTextUnnormalized = 1.0;
^
cpp/Beam.hpp:50:19: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
bool m_useNGrams = false;
^
cpp/Beam.hpp:51:23: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
bool m_forcastNGrams = false;
^
cpp/Beam.hpp:52:22: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
bool m_sampleNGrams = false;
^
cpp/Beam.hpp:56:52: error: a space is required between consecutive right angle brackets (use '> >')
std::pair<double, std::vector<std::vector<uint32_t>>> getNextWordsSampled(const std::shared_ptr& lm, const std::vector<uint32_t>& text) const;
^~
> >
cpp/Beam.hpp:68:34: error: a space is required between consecutive right angle brackets (use '> >')
std::vector<std::shared_ptr> getBestBeams(size_t beamWidth);
^~
> >
cpp/Beam.cpp:29:51: error: a space is required between consecutive right angle brackets (use '> >')
std::pair<double, std::vector<std::vector<uint32_t>>> Beam::getNextWordsSampled(const std::shared_ptr& lm, const std::vector<uint32_t>& text) const
^~
> >
cpp/Beam.cpp:32:2: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto nextWords=lm->getNextWords(text);
^
cpp/Beam.cpp:50:8: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
const auto& wordChars(newBeam->m_lm->getWordChars());
^
cpp/Beam.cpp:60:36: error: a space is required between consecutive right angle brackets (use '> >')
std::vector<std::vector<uint32_t>> nextWords;
^~
> >
cpp/Beam.cpp:62:9: error: no member named 'tie' in namespace 'std'
std::tie(sampleFactor, nextWords) = getNextWordsSampled(newBeam->m_lm, newBeam->m_wordDev);
~~~~~^
cpp/Beam.cpp:69:16: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (const auto& w : nextWords)
^
cpp/Beam.cpp:69:24: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (const auto& w : nextWords)
^
cpp/Beam.cpp:76:11: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
const auto& lastWord = newBeam->m_wordHist.back();
^
cpp/Beam.cpp:77:16: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (const auto& w : nextWords)
^
cpp/Beam.cpp:77:24: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (const auto& w : nextWords)
^
cpp/Beam.cpp:130:10: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
const auto& wordChars(newBeam->m_lm->getWordChars());
^
cpp/Beam.cpp:170:8: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
const auto nextWords=m_lm->getNextWords(m_wordDev);
^
cpp/Beam.cpp:176:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
const auto& completeWord = nextWords[0];
^
cpp/Beam.cpp:187:2: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto iter=m_beams.find(beam->getText());
^
cpp/Beam.cpp:199:33: error: a space is required between consecutive right angle brackets (use '> >')
std::vector<std::shared_ptr> BeamList::getBestBeams(size_t beamWidth)
^~
> >
cpp/Beam.cpp:202:63: error: a space is required between consecutive right angle brackets (use '> >')
typedef std::pair<std::vector<uint32_t>, std::shared_ptr> KeyValueType;
^~
> >
cpp/Beam.cpp:208:4: error: expected expression
,[](const KeyValueType& a, const KeyValueType& b) {return a.second->getTotalProb()*a.second->getTextualProb() > b.second->getTotalProb()*b.second->getTextualProb(); }
^
cpp/Beam.cpp:212:34: error: a space is required between consecutive right angle brackets (use '> >')
std::vector<std::shared_ptr> res;
^~
> >
26 warnings and 15 errors generated.
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: legacy-install-failure

× Encountered error while trying to install package.
╰─> word-beam-search

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

from ctcwordbeamsearch.

Maisteru avatar Maisteru commented on July 18, 2024

@SoroushMB thanks man for your effort!

from ctcwordbeamsearch.

UniDuEChristianGold avatar UniDuEChristianGold commented on July 18, 2024

I had the same issue on my Mac too. I solved it using @githubharalds' solution adding the extra arg.

setup.py line 8:

word_beam_search_ext = Extension('word_beam_search', sources=src, include_dirs=inc, language='c++', extra_compile_args=['-std=c++11'])

from ctcwordbeamsearch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.