angeloskath / supervised-lda

A flexible variational inference LDA library.
MIT License
22 stars 5 forks source link

Problem with installation (make) #21

Closed ChristianMichelsen closed 5 years ago

ChristianMichelsen commented 5 years ago

Hi and thanks for making this interesting piece of software!

I have for quite some time now tried to install LDA++ on my Macbook Pro (Mojave). I downloaded the software and followed your installation guide. I ran cmake -DCMAKE_BUILD_TYPE=Release .. without problems:

Michelsen-MacBook-Pro:build michelsen$ cmake -DCMAKE_BUILD_TYPE=Release ..
-- The C compiler identification is AppleClang 10.0.0.10001044
-- The CXX compiler identification is AppleClang 10.0.0.10001044
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Eigen: /usr/local/include/eigen3
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Found Docopt: /usr/local/include
-- Found GTest: /usr/local/lib/libgtest.a
-- Could NOT find BashCompletion (missing: BASHCOMPLETION_PATH)
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/michelsen/software/supervised-lda/build

but when running make I get an error after 2%:

Michelsen-MacBook-Pro:build michelsen$ make
Scanning dependencies of target ldaplusplus
[  2%] Building CXX object CMakeFiles/ldaplusplus.dir/src/ldaplusplus/Document.cpp.o
In file included from /Users/michelsen/software/supervised-lda/src/ldaplusplus/Document.cpp:6:
/Users/michelsen/software/supervised-lda/include/ldaplusplus/utils.hpp:14:39: error: implicit instantiation of undefined template
      'std::__1::array<double, 1024>'
static const std::array<double, 1024> exp_lut = {
                                      ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__tuple:223:64: note: template is declared here
template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
                                                               ^
1 error generated.
make[2]: *** [CMakeFiles/ldaplusplus.dir/src/ldaplusplus/Document.cpp.o] Error 1
make[1]: *** [CMakeFiles/ldaplusplus.dir/all] Error 2
make: *** [all] Error 2

Does anybody have any tips on how to deal with this problem?

Thanks a lot and sorry for the possibly dumb question (I'm pretty new to CMake and make) :-)

Cheers, Christian

angeloskath commented 5 years ago

Hi,

Thanks for the good words. Looking around based on the error you reported, I found that a couple of headers were missing. Probably some other implementation of the stdlib imported different headers or something.

In any way it is a bug on our part and I just pushed a probable fix. Let me know if you are still having problems.

Cheers, Angelos

ChristianMichelsen commented 5 years ago

Hi Angelos,

I just pulled your new version and it is now running until 8% instead of the initial 2%, so definitely something worked - however, there're still a bit of way to go:

Michelsen-MacBook-Pro:build michelsen$ make
Scanning dependencies of target ldaplusplus
[  2%] Building CXX object CMakeFiles/ldaplusplus.dir/src/ldaplusplus/Document.cpp.o
[  5%] Building CXX object CMakeFiles/ldaplusplus.dir/src/ldaplusplus/em/AbstractEStep.cpp.o
[  8%] Building CXX object CMakeFiles/ldaplusplus.dir/src/ldaplusplus/em/CorrespondenceSupervisedEStep.cpp.o
In file included from /Users/michelsen/software/supervised-lda/src/ldaplusplus/em/CorrespondenceSupervisedEStep.cpp:2:
In file included from /Users/michelsen/software/supervised-lda/include/ldaplusplus/em/CorrespondenceSupervisedEStep.hpp:4:
In file included from /Users/michelsen/software/supervised-lda/include/ldaplusplus/em/AbstractEStep.hpp:4:
/Library/Developer/CommandLineTools/usr/include/c++/v1/random:3646:44: error: non-type template argument is not a constant expression
    const size_t __logR = __log2<uint64_t, _URNG::max() - _URNG::min() + uint64_t(1)>::value;
                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/random:3778:18: note: in instantiation of function template specialization 'std::__1::generate_canonical<double, 53,
      ldaplusplus::math_utils::ThreadSafePRNG<std::__1::linear_congruential_engine<unsigned int, 48271, 0, 2147483647> > >' requested here
        * _VSTD::generate_canonical<_RealType, numeric_limits<_RealType>::digits>(__g)
                 ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/random:3742:17: note: in instantiation of function template specialization
      'std::__1::uniform_real_distribution<double>::operator()<ldaplusplus::math_utils::ThreadSafePRNG<std::__1::linear_congruential_engine<unsigned int, 48271, 0, 2147483647> > >' requested here
        {return (*this)(__g, __p_);}
                ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/random:3891:12: note: in instantiation of function template specialization
      'std::__1::uniform_real_distribution<double>::operator()<ldaplusplus::math_utils::ThreadSafePRNG<std::__1::linear_congruential_engine<unsigned int, 48271, 0, 2147483647> > >' requested here
    return __gen(__g) < __p.p();
           ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/random:3858:17: note: in instantiation of function template specialization
      'std::__1::bernoulli_distribution::operator()<ldaplusplus::math_utils::ThreadSafePRNG<std::__1::linear_congruential_engine<unsigned int, 48271, 0, 2147483647> > >' requested here
        {return (*this)(__g, __p_);}
                ^
/Users/michelsen/software/supervised-lda/src/ldaplusplus/em/CorrespondenceSupervisedEStep.cpp:88:9: note: in instantiation of function template specialization
      'std::__1::bernoulli_distribution::operator()<ldaplusplus::math_utils::ThreadSafePRNG<std::__1::linear_congruential_engine<unsigned int, 48271, 0, 2147483647> > >' requested here
    if (emit_likelihood(this->get_prng())) {
        ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/random:3646:44: note: non-constexpr function 'max' cannot be used in a constant expression
    const size_t __logR = __log2<uint64_t, _URNG::max() - _URNG::min() + uint64_t(1)>::value;
                                           ^
/Users/michelsen/software/supervised-lda/include/ldaplusplus/utils.hpp:599:28: note: declared here
        static result_type max() { return PRNG::max(); }
                           ^
1 error generated.
make[2]: *** [CMakeFiles/ldaplusplus.dir/src/ldaplusplus/em/CorrespondenceSupervisedEStep.cpp.o] Error 1
make[1]: *** [CMakeFiles/ldaplusplus.dir/all] Error 2
make: *** [all] Error 2
angeloskath commented 5 years ago

Hmm, that is a weird one. The code compiles fine in my machine (Debian "stretch") with gcc 6.3.

I checked the UniformRandomBitGenerator concept and apparently it requires that min() and max() are constant expressions. Thus I did another fix. Sorry for the trouble. I should somehow test with different platforms and compilers.

Let me know if this fixes your issue.

Cheers, Angelos

ChristianMichelsen commented 5 years ago

Sorry, it's continuing.. This time made it to 11%:

Michelsen-MacBook-Pro:build michelsen$ make
Scanning dependencies of target ldaplusplus
[  2%] Building CXX object CMakeFiles/ldaplusplus.dir/src/ldaplusplus/Document.cpp.o
[  5%] Building CXX object CMakeFiles/ldaplusplus.dir/src/ldaplusplus/em/AbstractEStep.cpp.o
[  8%] Building CXX object CMakeFiles/ldaplusplus.dir/src/ldaplusplus/em/CorrespondenceSupervisedEStep.cpp.o
[ 11%] Building CXX object CMakeFiles/ldaplusplus.dir/src/ldaplusplus/em/CorrespondenceSupervisedMStep.cpp.o
/Users/michelsen/software/supervised-lda/src/ldaplusplus/em/CorrespondenceSupervisedMStep.cpp:83:16: error: explicit instantiation of 'ldaplusplus::em::CorrespondenceSupervisedMStep' must occur in namespace 'em'
template class CorrespondenceSupervisedMStep<float>;
               ^
/Users/michelsen/software/supervised-lda/include/ldaplusplus/em/CorrespondenceSupervisedMStep.hpp:30:7: note: explicit instantiation refers here
class CorrespondenceSupervisedMStep : public MStepInterface<Scalar>
      ^
/Users/michelsen/software/supervised-lda/src/ldaplusplus/em/CorrespondenceSupervisedMStep.cpp:84:16: error: explicit instantiation of 'ldaplusplus::em::CorrespondenceSupervisedMStep' must occur in namespace 'em'
template class CorrespondenceSupervisedMStep<double>;
               ^
/Users/michelsen/software/supervised-lda/include/ldaplusplus/em/CorrespondenceSupervisedMStep.hpp:30:7: note: explicit instantiation refers here
class CorrespondenceSupervisedMStep : public MStepInterface<Scalar>
      ^
2 errors generated.
make[2]: *** [CMakeFiles/ldaplusplus.dir/src/ldaplusplus/em/CorrespondenceSupervisedMStep.cpp.o] Error 1
make[1]: *** [CMakeFiles/ldaplusplus.dir/all] Error 2
make: *** [all] Error 2
angeloskath commented 5 years ago

Wow, goes to say that gcc is ignoring a lot of mistakes!!! So I fixed that as well, it just required enclosing the forward template declarations in the em namespace.

Anyway, let me know if you still have problems.

Angelos

ChristianMichelsen commented 5 years ago

Dear Angelos,

It is building without problems now! It also installed without problems. I made a test and it came with a lot of warnings, among the most common of them was:

/Users/michelsen/software/supervised-lda/test/test_approximate_supervised_expectation_step.cpp:17:1: warning: 'TypedTestCaseIsDeprecated' is deprecated: TYPED_TEST_CASE is deprecated, please use TYPED_TEST_SUITE
      [-Wdeprecated-declarations]
TYPED_TEST_CASE(TestApproximateSupervisedExpectationStep, ForFloatAndDouble);
^
/usr/local/include/gtest/gtest-typed-test.h:230:38: note: expanded from macro 'TYPED_TEST_CASE'
  static_assert(::testing::internal::TypedTestCaseIsDeprecated(), ""); \
                                     ^

(a lot of those), one of:

/Users/michelsen/software/supervised-lda/test/test_numpy_data.cpp:95:33: warning: 'tmpnam' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of tmpnam(3),
      it is highly recommended that you use mkstemp(3) instead. [-Wdeprecated-declarations]
    std::string filename = std::tmpnam(nullptr);
                                ^

and finally some:

/Users/michelsen/software/supervised-lda/test/test_multinomial_supervised_expectation_step.cpp:109:15: warning: unused variable 'likelihood_unsupervised' [-Wunused-variable]
    TypeParam likelihood_unsupervised = e_step_utils::compute_supervised_likelihood(
              ^

In the final overview it passed almost all checks except:

[----------] 2 tests from TestSecondOrderMultinomialLogisticRegression/0, where TypeParam = float
[ RUN      ] TestSecondOrderMultinomialLogisticRegression/0.Gradient
[       OK ] TestSecondOrderMultinomialLogisticRegression/0.Gradient (0 ms)
[ RUN      ] TestSecondOrderMultinomialLogisticRegression/0.MinimizerOverfitSmall
/Users/michelsen/software/supervised-lda/test/test_second_order_mlr_approximation.cpp:125: Failure
Expected: (0.1) > (mlr.value(eta)), actual: 0.1 vs 0.109086
[  FAILED  ] TestSecondOrderMultinomialLogisticRegression/0.MinimizerOverfitSmall, where TypeParam = float (62 ms)
[----------] 2 tests from TestSecondOrderMultinomialLogisticRegression/0 (62 ms total)

[----------] 2 tests from TestSecondOrderMultinomialLogisticRegression/1, where TypeParam = double
[ RUN      ] TestSecondOrderMultinomialLogisticRegression/1.Gradient
[       OK ] TestSecondOrderMultinomialLogisticRegression/1.Gradient (0 ms)
[ RUN      ] TestSecondOrderMultinomialLogisticRegression/1.MinimizerOverfitSmall
[       OK ] TestSecondOrderMultinomialLogisticRegression/1.MinimizerOverfitSmall (76 ms)
[----------] 2 tests from TestSecondOrderMultinomialLogisticRegression/1 (76 ms total)

[----------] Global test environment tear-down
[==========] 49 tests from 25 test suites ran. (690 ms total)
[  PASSED  ] 48 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] TestSecondOrderMultinomialLogisticRegression/0.MinimizerOverfitSmall, where TypeParam = float

 1 FAILED TEST
[100%] Built target check

In addition to the errors above, I can tell you that all the benchmark tests ran smoothly:

Michelsen-MacBook-Pro:build michelsen$ ./bench_compute_approximate_phi
0.141173s
(DNA) Michelsen-MacBook-Pro:build michelsen$ ./bench_compute_unsupervised_phi
0.10989s
(DNA) Michelsen-MacBook-Pro:build michelsen$ ./bench_compute_supervised_phi_gamma
6.91985s
(DNA) Michelsen-MacBook-Pro:build michelsen$ ./bench_compute_h
2.06059s

I will test the actual software sometime Monday and let you know my results, but I will just thank you a lot for your quick responses and very useful help!

angeloskath commented 5 years ago

Closing since there are no more issues building with Clang.