bayesmix-dev / bayesmix

Flexible Bayesian nonparametric mixture models in C++
https://bayesmix.rtfd.io
BSD 3-Clause "New" or "Revised" License
22 stars 18 forks source link

Do we still use system TBB? #65

Closed brunoguindani closed 2 years ago

brunoguindani commented 3 years ago

When I was setting everything back up the other day, after correct compilation and linking, run.cc stopped cold at the beninning saying it could not find libtbb.so.2. I checked in the appropriate folder lib/math/lib/tbb and it was there, alongside libtbb.so. This means that the Python script for building it was successfully executed. I tried installing TBB via APT just for giggles (actually more out of desperation) and it worked! I mean, it's fine to require a system version, we do that with other libraries, but I think it's not supposed to work like this.

mberaha commented 3 years ago

This is strange, when developing pybmix I tested on several clean machines the install and for sure I did not get any error (and tbb was not present since the machine was a virtualbox with an empty ubuntu). It's worth digging though!

brunoguindani commented 3 years ago

I know right. This has never happened to me in the past either. I think the only difference is that this time, I set it up on Ubuntu 18.04, while past machines/VMs always had 20.04. Several packages there use outdated versions, and this might have to do with the error. It' worth digging for sure, since we might expect people to run this from 18.04, being an LTS distro and all.

brunoguindani commented 2 years ago

Unfortunately the issue is still there. The same thing as the one mentioned in the OP just happened again, even when cloning and installing the library from scratch. Similarly, it was fixed after manual installation of libtbb-dev (I have since changed computer and it was not installed there yet).

mberaha commented 2 years ago

FML

TeoGiane commented 2 years ago

OK, I guess we are now able to close this issue (HOPEFULLY).

In order to link against source TBB available in math, I relied on their own tutorial available here. Basically, inside CMakeLists.txt, I check if TBB is already available in the system or not. If not, we move files to the tbb folder (ignored by stan/math) and then call tbb_build (defined in this cmake file), which builds the library and provide necessary targets to properly include and link against it.

To make it fully functional, though, I had to comment set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) in CMakeLists.txt. Moreover, with this changes we do not need the build_tbb cmake target as well as the build_tbb.py python module.