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

Using TBB with numba fails with pip install, works with apt install #7148

Closed
2 tasks done
theahura opened this issue Jun 25, 2021 · 19 comments
Closed
2 tasks done

Using TBB with numba fails with pip install, works with apt install #7148

theahura opened this issue Jun 25, 2021 · 19 comments
Labels
installation issue with installation question Notes an issue as a question stale Marker label for stale issues. threading Issue involving the threading layers

Comments

@theahura
Copy link

Reporting a bug

  • I have tried using the latest released version of Numba (most recent is
    visible in the change log (https://github.com/numba/numba/blob/master/CHANGE_LOG).
  • I have included a self contained code sample to reproduce the problem.
    i.e. it's possible to run as 'python bug.py'.

Basically the title. Running the following commands fails:

python3 -m venv env
source env/bin/activate
pip install tbb numba
numba -s | grep TBB

Specifically, this returns:

TBB Threading Layer Available                 : False

The following does work:

sudo apt install libtbb-dev
numba -s | grep TBB

returning

TBB Threading Layer Available                 : True
+-->TBB imported successfully.

Two guesses.

  1. The tbb version on pypi is bricked.
  2. Numba is looking for a specific path that doesn't exist when installing with pip, but does exist when you install from apt.
@stuartarchibald
Copy link
Contributor

@theahura Thanks for the report. Is the issue perhaps this: #6108 (comment) ?

@stuartarchibald stuartarchibald added threading Issue involving the threading layers installation issue with installation question Notes an issue as a question labels Jun 25, 2021
@esc
Copy link
Member

esc commented Jun 25, 2021

Which tbb and tbb-devel did you install from PyPi? I think you may need https://pypi.org/project/tbb/2020.3.254/ ?

@theahura
Copy link
Author

@esc that version did not fix any issues.

@stuartarchibald seems like that could be related. I'm using a virtualenv, as the original post shows. I'm a bit confused by the linked comment's suggestion, however. It seems like you're saying the libtbb file isn't in the right place.

Where is the file located currently? (I see a bunch of libtbb.so files in env/lib).
And where does it need to go?

@esc
Copy link
Member

esc commented Jun 29, 2021

Where is the file located currently? (I see a bunch of libtbb.so files in env/lib).
And where does it need to go?

I'm not sure anyone knows for certain. During our issue triage yesterday we discussed this and apparently the location of where to place libraries is a compile-time flag of the python interpreter. This means, the location will most likely be different depending on who compiled your python and thus, where you obtained it from.

Another issue, is that wheels were not designed as a binary packaging format. That is, the tbb package does not ship any Python code, only a compiled shared object / library and it's "not really" a properly supported use-case. We have asked about this before and you can read more here:

https://github.com/numba/numba/pulls?q=is%3Aopen+is%3Apr+milestone%3A%22Numba+0.54+RC%22

Incidentally, we actually have a script that unpacks the wheel we generate and removes libtbb.so again and repackages the wheel so that people can (if they are lucky). pip install tbb and have that work.

So, what I would recommend perhaps, is to point the LD_LIBRARY_PATH to the location of the libtbb.so file an try to launch it like that.

Hope that helps!

@esc
Copy link
Member

esc commented Jun 29, 2021

I'm so sorry, I posted the wrong link, the correct one is here:

https://discuss.python.org/t/how-to-disable-vendoring-of-libraries-in-wheel/5010

@github-actions
Copy link

This issue is marked as stale as it has had no activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with any updates and confirm that this issue still needs to be addressed.

@github-actions github-actions bot added the stale Marker label for stale issues. label Jul 30, 2021
@gmarkall
Copy link
Member

Closing this issue as the question appears to be answered and no further feedback has been received.

@theahura
Copy link
Author

FYI: this approach seems to break with newer versions of numba. I can confirm that it works with 0.52.0, but not with 0.55.1

@esc
Copy link
Member

esc commented Feb 17, 2022

FYI: this approach seems to break with newer versions of numba. I can confirm that it works with 0.52.0, but not with 0.55.1

Question: with "this approach", you mean the approach of apt installing tbb? Is that broken with 0.55.1? Does tbb work with pip at all?

@theahura
Copy link
Author

Question: with "this approach", you mean the approach of apt installing tbb?

Yes

Is that broken with 0.55.1? Does tbb work with pip at all?

Yes it's broken. I think it's a versioning thing, apt has tbb2020 but I believe numba is looking for tbb2021.

Pip tbb doesn't work at all, at least I couldn't get it working

@esc
Copy link
Member

esc commented Feb 17, 2022

Is that broken with 0.55.1? Does tbb work with pip at all?

Yes it's broken. I think it's a versioning thing, apt has tbb2020 but I believe numba is looking for tbb2021.

W/o seeing the exact errors, this is probably correct.

Pip tbb doesn't work at all, at least I couldn't get it working

This may be worth opening a new issue about. If pip install tbb is really broken, the developers of that software should probably be notified. Do you perhaps recall or can you re-generate the error message you received with this?

@theahura
Copy link
Author

This minimal example still replicates:

python3 -m venv env
source env/bin/activate
pip install tbb numba
numba -s | grep TBB

I get

__Threading Layer Information__                                                                      
TBB Threading Layer Available                 : False                                                
+--> Disabled due to Unknown import problem.                                                         

I had a hunch that the venv may have been the issue, but even a global install did not fix the issue. For my own project, I had to just pull tbb out because it was causing too many dependency issues 😞

I'm not even sure what pip install tbb does. The site-packages are basically empty, and I couldn't find where it dumped the libtbb.so files 🤔

@esc
Copy link
Member

esc commented Feb 17, 2022

@theahura thank you, which platform is this?

@theahura
Copy link
Author

Ubuntu 20 Desktop

@esc
Copy link
Member

esc commented Feb 17, 2022

I can confirm this is still an issue that will need to be triaged.

zsh» python3 -m venv venv
zsh» source venv/bin/activate
zsh» pip install numba tbb
Collecting numba
  Downloading numba-0.55.1-1-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (3.4 MB)
     |████████████████████████████████| 3.4 MB 2.0 MB/s 
Collecting tbb
  Downloading tbb-2021.5.1-py2.py3-none-manylinux1_x86_64.whl (4.0 MB)
     |████████████████████████████████| 4.0 MB 4.6 MB/s 
Requirement already satisfied: setuptools in ./venv/lib/python3.8/site-packages (from numba) (44.0.0)
Collecting numpy<1.22,>=1.18
  Downloading numpy-1.21.5-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.7 MB)
     |████████████████████████████████| 15.7 MB 90 kB/s 
Collecting llvmlite<0.39,>=0.38.0rc1
  Downloading llvmlite-0.38.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (34.5 MB)
     |████████████████████████████████| 34.5 MB 3.5 MB/s 
Installing collected packages: numpy, llvmlite, numba, tbb
Successfully installed llvmlite-0.38.0 numba-0.55.1 numpy-1.21.5 tbb-2021.5.1
pip install numba tbb  9,43s user 1,95s system 46% cpu 24,336 total
zsh» which numba
/tmp/venv/bin/numba
zsh» numba -s | grep TBB 
TBB Threading Layer Available                 : False
zsh» cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.3 LTS"

@esc esc reopened this Feb 17, 2022
@github-actions github-actions bot removed the stale Marker label for stale issues. label Feb 18, 2022
@stuartarchibald
Copy link
Contributor

@esc is this issue down to this: #6108 (comment) ?

@esc
Copy link
Member

esc commented Feb 18, 2022

@esc is this issue down to this: #6108 (comment) ?

It certainly sounds plausible.

@github-actions
Copy link

This issue is marked as stale as it has had no activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with any updates and confirm that this issue still needs to be addressed.

@github-actions github-actions bot added the stale Marker label for stale issues. label Mar 21, 2022
@nathzi1505
Copy link

nathzi1505 commented May 10, 2023

Where is the file located currently? (I see a bunch of libtbb.so files in env/lib).
And where does it need to go?

I'm not sure anyone knows for certain. During our issue triage yesterday we discussed this and apparently the location of where to place libraries is a compile-time flag of the python interpreter. This means, the location will most likely be different depending on who compiled your python and thus, where you obtained it from.

Another issue, is that wheels were not designed as a binary packaging format. That is, the tbb package does not ship any Python code, only a compiled shared object / library and it's "not really" a properly supported use-case. We have asked about this before and you can read more here:

https://github.com/numba/numba/pulls?q=is%3Aopen+is%3Apr+milestone%3A%22Numba+0.54+RC%22

Incidentally, we actually have a script that unpacks the wheel we generate and removes libtbb.so again and repackages the wheel so that people can (if they are lucky). pip install tbb and have that work.

So, what I would recommend perhaps, is to point the LD_LIBRARY_PATH to the location of the libtbb.so file an try to launch it like that.

Hope that helps!

TL;DR: This works.
After you install through pip install --upgrade tbb set your LD_LIBRARY_PATH to the .../venv/lib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installation issue with installation question Notes an issue as a question stale Marker label for stale issues. threading Issue involving the threading layers
Projects
None yet
Development

No branches or pull requests

5 participants