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

Error installing coinutils on Mac M1 #62

Closed
dirkschumacher opened this issue Mar 3, 2021 · 32 comments
Closed

Error installing coinutils on Mac M1 #62

dirkschumacher opened this issue Mar 3, 2021 · 32 comments

Comments

@dirkschumacher
Copy link

I have a MacBook M1 here and just tried to install coinutils but it fails on make test

brew install coin-or-tools/coinor/coinutils
==> Installing coinutils from coin-or-tools/coinor
==> Downloading https://www.coin-or.org/download/pkgsource/CoinUtils/CoinUtils-2
==> ./configure --prefix=/opt/homebrew/Cellar/coinutils/2.11.3 --datadir=/opt/ho
==> make
==> make test
Last 15 lines from /Users/dsp/Library/Logs/Homebrew/coinutils/03.make:
need to fill in rows
before pass 45 with seed of 464143
before pass 46 with seed of 858620
need to fill in rows
before pass 47 with seed of 938599
before pass 48 with seed of 643306
before pass 49 with seed of 596504
Time for 50 CoinModel passes is 0.003984 seconds

Testing CoinError
Testing CoinShallowPackedVector
Testing CoinPackedVector
Assertion failed: (r.isEquivalent(rV)), function CoinPackedVectorUnitTest, file CoinPackedVectorTest.cpp, line 707.
make[1]: *** [test] Abort trap: 6
make: *** [test] Error 2
@tkralphs
Copy link
Member

tkralphs commented Mar 3, 2021

This doesn't really seem to be a problem with the homebrew recipe per se, but just an issue with CoinUtils itself. Looks like it should be easy to isolate and debug. It's a failure of a test dividing a packed vector by an empty (all zeros) packed vector element-wise. So it's basically testing what happens when we divide by zero. The result is apparently supposed to be "infinity" and I guess what is failing here is that the compiler must not be adhering to some IEEE standard or another. This looks like a failure that is unlikely to affect any real computation. I can't imagine a solver actually performing this operation, but technically, it should work.

It's going to be hard to track down without direct access to an M1 box, but if you're willing, it shouldn't be too difficult to see what's going on by just building CoinUtils with debugging enabled and running the unit (or pulling it out into a small demonstration code).

The operator being tested is defined here:

https://github.com/coin-or/CoinUtils/blob/dcd230bbecbb7f8df0191e13d505274b1bf462da/CoinUtils/src/CoinPackedVector.cpp#L300

and the test itself is here:

https://github.com/coin-or/CoinUtils/blob/dcd230bbecbb7f8df0191e13d505274b1bf462da/CoinUtils/test/CoinPackedVectorTest.cpp#L707

Maybe you could open an issue in CoinUtils (I can't transfer this one, since it's in a different organization).

@Alexander-Belyi
Copy link
Contributor

I've got the same problem and tried to debug it. Here's what I've found:

  1. The test fails because COIN_C_FINITE doesn’t get defined during config, then infty variable gets assigned COIN_DBL_MAX, and later comparison to double infinity fails. In general, tests' logic in the case when COIN_C_FINITE isn't defined doesn't seem correct to me. Similar happens in unitTest.cpp, when building coinutils, I get
    Testing CoinIsnan ... finite value: ok; NaN value: ERROR.
    because in line 163: checkVal = checkVal/checkVal ;
    when COIN_C_FINITE isn't defined this becomes checkVal = COIN_DBL_MAX/COIN_DBL_MAX == 1 which is then compared to nan.
  2. COIN_C_FINITE doesn't get defined because isfinite is overloaded and casting it to void* fails at line
    void *p = (void *) isfinite;
    I'm attaching full config.log for more details. One can search for WARNING: Cannot find C-function for checking Inf. to see the relevant part.
  3. This problem is fixed in master branch of coinutils. There, presence of isfinite is tested by trying (void) std::isfinite(1.0) ;.

So, I hope that current development from master will soon be released as new version, and that homebrew formulas will be updated accordingly. For now I will stick to building from source.

@tkralphs
Copy link
Member

tkralphs commented Aug 5, 2021

@Alexander-Belyi Thanks very much for following up and for this explanation. I'm hoping we can indeed get the master version of CoinUtils into release soon. Stay tuned!

@mmiller-max
Copy link

@tkralphs just wondering if there was any update on the next CoinUtils release? Cheers!

@tkralphs
Copy link
Member

tkralphs commented Nov 3, 2021

I made some progress, but not there yet, thanks for the ping. Optimistically, I will get to it soon!

@mmiller-max
Copy link

Great, thanks for the update!

@EmiFej
Copy link

EmiFej commented Nov 20, 2021

Hi all. While installing CBC using Brew I got the same message I believe as @dirkschumacher above:

Testing CoinError
Testing CoinShallowPackedVector
Testing CoinPackedVector
Assertion failed: (r.isEquivalent(rV)), function CoinPackedVectorUnitTest, file CoinPackedVectorTest.cpp, line 707.
make[1]: *** [test] Abort trap: 6
make: *** [test] Error 2

After which I tried to run cbc for solving a model I have created. But when I enter "cbc" in the terminal I get the following:
zsh: command not found: cbc

Is this due to the fact that I have a M1 Pro processor and that the issue with coinutils remains? :)

@tkralphs
Copy link
Member

Is this due to the fact that I have a M1 Pro processor and that the issue with coinutils remains? :)

Yes, exactly. The build process never completed, so there is no cbc at the end. It is easy to install the master version of Cbc, though, using coinbrew and that should work fine as a stop gap.

tkralphs added a commit to coin-or/CoinUtils that referenced this issue Jan 7, 2022
@tkralphs
Copy link
Member

I've finally found some time to look into this and do some releases. Sorry for the long delay---the fix I landed on turned out not to be too difficult. As @Alexander-Belyi made clear above, this test just doesn't make sense when COIN_C_FINITE is not defined. Even though COIN_C_FINITE would be defined in the master version (so this issue wouldn't arise there), it is true even in master that we should not do this test when COIN_C_FINITE is not defined, so I have made this change in both places and this should fix this issue.

I made the new release that should fix this, but I'm having major troubles upgrading packages on my now very old OS X box that I use for testing, so I haven't been able to push the changes to the recipe. If anyone wants to do this and open a PR, that would be helpful. The download URL should be changed to Github: https://github.com/coin-or/CoinUtils/archive/refs/tags/releases/2.11.5.tar.gz. There is also a recipe in homebrew core that I assume will get an auto update (?), so that could also be an easier path. I'll be making releases for all the packages in the Cbc stack in the next day or two (Osi is also done already), so all will need to be modified.

@mmiller-max
Copy link

mmiller-max commented Jan 10, 2022

@tkralphs this is great, thanks!

I'm happy to help with this, just don't quite know the steps to go through. Is it a case of updating coinutils.rb to point to the latest release, and them somehow testing it locally?

Edit - I see you say what to do so it's just testing locally that needs doing.

@tkralphs
Copy link
Member

If you just do brew edit coin-or-tools/coinor/coinutils, pop in the new URL, and then try to reinstall, it should give you an error about the SHAs not matching. As part of the error, it will give you the new SHA. which you can then paste in to the recipe the same way. Trying again, it should download the new source and install. If it all works, then you can either open a PR with the changes or also just paste the new SHA here and I will update it manually.

@mmiller-max
Copy link

mmiller-max commented Jan 10, 2022

I'm seeing the same error, is it possible that something is being cached?

% brew reinstall coin-or-tools/coinor/coinutils
==> Downloading https://github.com/coin-or/CoinUtils/archive/refs/tags/releases/2.11.5.tar.gz
==> Downloading from https://codeload.github.com/coin-or/CoinUtils/tar.gz/refs/tags/releases/2.11.5
   #-=#=-#    #                                                               
==> Reinstalling coin-or-tools/coinor/coinutils 
==> ./configure --prefix=/opt/homebrew/Cellar/coinutils/2.11.5 --datadir=/opt/homebrew/Cellar/coinutils/2.11.5/share/coin
==> make
==> make test
Last 15 lines from /Users/max/Library/Logs/Homebrew/coinutils/03.make:
before pass 45 with seed of 464143
before pass 46 with seed of 858620
need to fill in rows
before pass 47 with seed of 938599
before pass 48 with seed of 643306
before pass 49 with seed of 596504
Time for 50 CoinModel passes is 0.001919 seconds

Testing CoinError
Testing CoinShallowPackedVector
Testing CoinPackedVector
Assertion failed: (r.isEquivalent(rV)), function CoinPackedVectorUnitTest, file CoinPackedVectorTest.cpp, line 707.
make[2]: *** [test] Abort trap: 6
make[1]: *** [test] Error 2
make: *** [test] Error 2

If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
  https://github.com/coin-or-tools/homebrew-coinor/issues

These open issues may also help:
Error installing coinutils on Mac M1 https://github.com/coin-or-tools/homebrew-coinor/issues/62

@tkralphs
Copy link
Member

tkralphs commented Jan 10, 2022

Argh, the failure analyzed by @Alexander-Belyi is actually different than the one originally reported, though they have the same cause. Looks like we need another release :). Oh well, this will give me a chance to further refine my release automation! Stay tuned...

@tkralphs
Copy link
Member

OK, there's now a release 2.11.6, which I tested by forcing COIN_C_FINITE to be undefined. Everything passed for me. Can you try it? Same procedure...

@Alexander-Belyi
Copy link
Contributor

Thanks, @tkralphs, for getting to this!
When describing the problem, I just meant that there's also another similar issue. Sorry for the confusion caused.
I've tried installing the new version, and it worked fine. I can also update hashes of other packages when new releases are ready.

Also, please, note that probably the second fix should be applied to master as well.

@dirkschumacher
Copy link
Author

Thanks everyone!

@tkralphs
Copy link
Member

Also, please, note that probably the second fix should be applied to master as well.

Yes, thanks for the reminder. This is done now. I assume that everything is working with the new releases and we can close this issue?

@Alexander-Belyi
Copy link
Contributor

Great, thanks. Yes, everything works for me.

@mmiller-max
Copy link

Also, please, note that probably the second fix should be applied to master as well.

Yes, thanks for the reminder. This is done now. I assume that everything is working with the new releases and we can close this issue?

Yes all working well, thanks!

@tkralphs
Copy link
Member

@Alexander-Belyi I've now made releases Clp 1.17.7, Cgl 0.60.4, and Cbc 2.10.6 as well.

@Alexander-Belyi
Copy link
Contributor

I've now made releases Clp 1.17.7, Cgl 0.60.4, and Cbc 2.10.6 as well.

@tkralphs Something is wrong with Cbc 2.10.6: the script gets stuck when running make test. It works well for the previous version 2.10.5. make test takes about 15 seconds to run, while for the new version I waited ~30 minutes and it's never reached make install.
Everything works for Clp and Cgl.

@tkralphs
Copy link
Member

Hmm, everything seems to go smoothly on CI and on my local tests.
https://github.com/coin-or/Cbc/actions/runs/1690241624
Are you building a debug version? Are you using coinbrew? If so, can you run it with --verbosity 4 and get the detailed output to know here it gets hung up. I did notice at one point that a debug version was getting hung up on the C API test for some reason.

@dirkschumacher
Copy link
Author

It worked fine for me on an M1 using the most recent homebrew formula.

@tkralphs
Copy link
Member

By the way, if anyone can easily help set up CI here, I would be grateful. I'm struggling to get homebrew packages upgraded on my old OS X box, so I currently have no way of doing any testing. I may just get a Mac mini one of these days, but in the meantime, it would be nice to have a robust CI working.

@dpo
Copy link
Contributor

dpo commented Jan 14, 2022

Yes, sir: #68

@tkralphs
Copy link
Member

@dpo Good to see you, thanks!

@Alexander-Belyi
Copy link
Contributor

Alexander-Belyi commented Jan 14, 2022

Are you building a debug version? Are you using coinbrew? If so, can you run it with --verbosity 4 and get the detailed output to know here it gets hung up. I did notice at one point that a debug version was getting hung up on the C API test for some reason.

No, I was just using the existing formula cbc.rb. When I try to build Cbc 2.10.6 or Cbc 2.10.5 using coinbrew, I'm getting this error:

##################################################
### Building ThirdParty/Metis 1.3.10 
##################################################

projects/coinbrew/ThirdParty/Metis/metis-4.0/Lib/compress.c:151:3: error: implicit declaration of function '__GKfree' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  GKfree(&keys, &map, &mark, LTERM);
  ^
projects/coinbrew/ThirdParty/Metis/metis-4.0/Lib/rename.h:380:19: note: expanded from macro 'GKfree'
#define GKfree                          __GKfree
                                        ^
1 error generated.
make: *** [compress.lo] Error 1

I don't see this dependency on Metis in cbc.rb nor in the master branch, so I assume that's why I don't get this error when building using them.

@tkralphs
Copy link
Member

Metis is an optional dependency, so you can build with --skip=ThirdParty/Metis to get past this error. Or just do --no-third-party to only build the COIN-OR codes. Everything will still work, those libraries just enable some additional functionality you probably won't benefit from anyway.

@Alexander-Belyi
Copy link
Contributor

Hmm, it builds without problems using coinbrew and --no-third-party. Do you have any suggestions on how I can debug installation from brew formula directly?

@tkralphs
Copy link
Member

If I recall, there are options --debug and --verbose to the brew command that will show you the build output and other information that might help.

@Alexander-Belyi
Copy link
Contributor

If I recall, there are options --debug and --verbose to the brew command that will show you the build output and other information that might help.

Thanks, yes, it helps.
So far, I've found that the reason for a seeming hung up is that instead of calling ../src/cbc -dirSample 'echo /opt/homebrew/opt/coin_data_sample/share/coin_data_sample/coin/Data/Sample' -unitTest, cbc is called without any parameters like ../src/cbc and the process stops at its command prompt. Now, I just need to figure out why it is happening.

@tkralphs
Copy link
Member

Ah, that helps. But it's weird... do you have the coin_data_sample package installed? I think if you can ctrl-C out of the build process, it will give you the option to drop into a shell in the build directory. Grab the config.log file and drop it here, I may be able to debug. But probably better to open a new issue for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants