-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
glibc: keg_only and optionally add system ld search paths #109998
Conversation
Now the formula In [1]: import ctypes
In [2]: libcuda = ctypes.CDLL('libcuda.so.1') # in /lib/x86_64-linux-gnu
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
Cell In [2], line 1
----> 1 libcuda = ctypes.CDLL('libcuda.so.1')
File /home/linuxbrew/.linuxbrew/opt/python@3.10/lib/python3.10/ctypes/__init__.py:374, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
371 self._FuncPtr = _FuncPtr
373 if handle is None:
--> 374 self._handle = _dlopen(self._name, mode)
375 else:
376 self._handle = handle
OSError: libcuda.so.1: cannot open shared object file: No such file or directory |
c45a7c5
to
01291c9
Compare
Please drop We need to be really careful about adding this, as mixing non-brewed libraries with brewed libraries by linkage like this can lead to all sorts of weird failures, especially if building from source. |
Yes, but since the
I think we should make |
Making it keg-only will also break many things at the moment so we will have to find a suitable compromise solution. I will do some local testing of this to figure out what the best solution, but my general inclination is to say that mixing brewed and system libraries when using brewed |
bbc5ddd
to
d4863d3
Compare
Brewed Python cannot import packages that ship shared libraries (e.g. $ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install --upgrade pip setuptools rich
$ pip3 install --upgrade torch $ python3 -c 'from rich import traceback; traceback.install(); import torch'
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ <string>:1 in <module> │
│ │
│ /home/PanXuehai/venv/lib/python3.10/site-packages/torch/__init__.py:201 in <module> │
│ │
│ 198 │ # │
│ 199 │ # See Note [Global dependencies] │
│ 200 │ if USE_GLOBAL_DEPS: │
│ ❱ 201 │ │ _load_global_deps() │
│ 202 │ from torch._C import * # noqa: F403 │
│ 203 │
│ 204 # Appease the type checker; ordinarily this binding is inserted by the │
│ │
│ /home/PanXuehai/venv/lib/python3.10/site-packages/torch/__init__.py:154 in _load_global_deps │
│ │
│ 151 │ here = os.path.abspath(__file__) │
│ 152 │ lib_path = os.path.join(os.path.dirname(here), 'lib', lib_name) │
│ 153 │ │
│ ❱ 154 │ ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL) │
│ 155 │
│ 156 │
│ 157 if (USE_RTLD_GLOBAL_WITH_LIBTORCH or os.getenv('TORCH_USE_RTLD_GLOBAL')) and \ │
│ │
│ /home/linuxbrew/.linuxbrew/opt/python@3.10/lib/python3.10/ctypes/__init__.py:374 in __init__ │
│ │
│ 371 │ │ self._FuncPtr = _FuncPtr │
│ 372 │ │ │
│ 373 │ │ if handle is None: │
│ ❱ 374 │ │ │ self._handle = _dlopen(self._name, mode) │
│ 375 │ │ else: │
│ 376 │ │ │ self._handle = handle │
│ 377 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
OSError: libstdc++.so.6: cannot open shared object file: No such file or directory We do have a $ fd '^libstdc++' "${HOMEBREW_PREFIX}"
/home/linuxbrew/.linuxbrew/Cellar/gcc/12.2.0/lib/gcc/12/libstdc++.a
/home/linuxbrew/.linuxbrew/Cellar/gcc/12.2.0/lib/gcc/12/libstdc++.so
/home/linuxbrew/.linuxbrew/Cellar/gcc/12.2.0/lib/gcc/12/libstdc++.so.6
/home/linuxbrew/.linuxbrew/Cellar/gcc/12.2.0/lib/gcc/12/libstdc++.so.6.0.30
/home/linuxbrew/.linuxbrew/Cellar/gcc/12.2.0/lib/gcc/12/libstdc++.so.6.0.30-gdb.py
/home/linuxbrew/.linuxbrew/Cellar/gcc/12.2.0/lib/gcc/12/libstdc++fs.a
/home/linuxbrew/.linuxbrew/Cellar/gcc/12.2.0/lib/gcc/current/libstdc++.a
/home/linuxbrew/.linuxbrew/Cellar/gcc/12.2.0/lib/gcc/current/libstdc++.so
/home/linuxbrew/.linuxbrew/Cellar/gcc/12.2.0/lib/gcc/current/libstdc++.so.6
/home/linuxbrew/.linuxbrew/Cellar/gcc/12.2.0/lib/gcc/current/libstdc++.so.6.0.30
/home/linuxbrew/.linuxbrew/Cellar/gcc/12.2.0/lib/gcc/current/libstdc++.so.6.0.30-gdb.py
/home/linuxbrew/.linuxbrew/Cellar/gcc/12.2.0/lib/gcc/current/libstdc++fs.a
/home/linuxbrew/.linuxbrew/Cellar/gcc/12.2.0/share/gcc-12/python/libstdcxx
/home/linuxbrew/.linuxbrew/Cellar/gcc@11/11.3.0/lib/gcc/11/libstdc++.a
/home/linuxbrew/.linuxbrew/Cellar/gcc@11/11.3.0/lib/gcc/11/libstdc++.so
/home/linuxbrew/.linuxbrew/Cellar/gcc@11/11.3.0/lib/gcc/11/libstdc++.so.6
/home/linuxbrew/.linuxbrew/Cellar/gcc@11/11.3.0/lib/gcc/11/libstdc++.so.6.0.29
/home/linuxbrew/.linuxbrew/Cellar/gcc@11/11.3.0/lib/gcc/11/libstdc++.so.6.0.29-gdb.py
/home/linuxbrew/.linuxbrew/Cellar/gcc@11/11.3.0/lib/gcc/11/libstdc++fs.a
/home/linuxbrew/.linuxbrew/Cellar/gcc@11/11.3.0/share/gcc-11/python/libstdcxx
/home/linuxbrew/.linuxbrew/Cellar/gcc@11/11.3.0.reinstall/lib/gcc/11/libstdc++.a
/home/linuxbrew/.linuxbrew/Cellar/gcc@11/11.3.0.reinstall/lib/gcc/11/libstdc++.so
/home/linuxbrew/.linuxbrew/Cellar/gcc@11/11.3.0.reinstall/lib/gcc/11/libstdc++.so.6
/home/linuxbrew/.linuxbrew/Cellar/gcc@11/11.3.0.reinstall/lib/gcc/11/libstdc++.so.6.0.29
/home/linuxbrew/.linuxbrew/Cellar/gcc@11/11.3.0.reinstall/lib/gcc/11/libstdc++.so.6.0.29-gdb.py
/home/linuxbrew/.linuxbrew/Cellar/gcc@11/11.3.0.reinstall/lib/gcc/11/libstdc++fs.a
/home/linuxbrew/.linuxbrew/Cellar/gcc@11/11.3.0.reinstall/share/gcc-11/python/libstdcxx
/home/linuxbrew/.linuxbrew/lib/gcc/12/libstdc++.a
/home/linuxbrew/.linuxbrew/lib/gcc/12/libstdc++.so
/home/linuxbrew/.linuxbrew/lib/gcc/12/libstdc++.so.6
/home/linuxbrew/.linuxbrew/lib/gcc/12/libstdc++.so.6.0.30
/home/linuxbrew/.linuxbrew/lib/gcc/12/libstdc++.so.6.0.30-gdb.py
/home/linuxbrew/.linuxbrew/lib/gcc/12/libstdc++fs.a
/home/linuxbrew/.linuxbrew/lib/gcc/current/libstdc++.a
/home/linuxbrew/.linuxbrew/lib/gcc/current/libstdc++.so
/home/linuxbrew/.linuxbrew/lib/gcc/current/libstdc++.so.6
/home/linuxbrew/.linuxbrew/lib/gcc/current/libstdc++.so.6.0.30
/home/linuxbrew/.linuxbrew/lib/gcc/current/libstdc++.so.6.0.30-gdb.py
/home/linuxbrew/.linuxbrew/lib/gcc/current/libstdc++fs.a
/home/linuxbrew/.linuxbrew/lib/libstdc++.so.6 |
The problem here is that It's worth reiterating here that the intended use case for brewed Python is really as a run time for Python applications rather than as a environment into which the user installs their own packages. Users should really use virtualenvs directly from Python or from Miniconda/Anaconda when they want to do things like install Python packages with |
d4863d3
to
be90dd4
Compare
be90dd4
to
78eb64f
Compare
@XuehaiPan Is upgrading to a distribution of Linux like Ubuntu 22.04 that provides Glibc 2.35 or newer an option for you? You wouldn't need to install the brewed |
I agree that users should upgrade when possible, but I'm warming up to this idea. I want to test it locally in the next day. One note: we need to drop all explicit |
78eb64f
to
2ca58b0
Compare
I'm afraid not. Most of my use cases for Homebrew on Linux are installing packages on Linux servers where I don't have Since the Ubuntu LTS versions provide 5 years long term support, the users are not meant to upgrade their system each time a new LTS version is released. Especially, the system is shared for multiple users, e.g., cloud services or ML servers. In Support Policy of GitHub Actions Runner and GitHub-hosted Runner Matrix, GitHub provides at least two GA version of an OS. And, currently
As discussed in Why always use the latest version?:
we always use the latest LTS version of Ubuntu to build bottles. But I wonder could we use the second latest LTS version ( |
We decided against this for a number of reasons. Our goal right now is to fix the underlying issues with brewed |
Making |
This change opens a hole can of worms mixing Homebrew shared libraries with host shared libraries which use different versions of Glibc. I expect there's fun ways it could breaks, but it also addresses real issues that arise primarily when trying to compile things from source outside of Homebrew, particularly installing packages for other programming languages using their package manager and building native extensions from source. It's certainly worth experimenting with this PR. A small historical note: Using |
6b06dc9
to
1296c4f
Compare
1296c4f
to
ff34880
Compare
ff34880
to
bee32b9
Compare
bee32b9
to
b164c44
Compare
Also: * Make linux-headers@5.15 a runtime dependency * Don't link ld.so in post-install (instead rely on behaviour within brew) * Use correct etc directory * Architecture-agnostic test * Ensure /tmp/homebrew is always cleaned Co-authored-by: Bo Anderson <mail@boanderson.me>
b164c44
to
fe7d8cb
Compare
Failed to build |
Yes. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
@Bo98 has triggered a merge. |
brew install --build-from-source <formula>
, where<formula>
is the name of the formula you're submitting?brew test <formula>
, where<formula>
is the name of the formula you're submitting?brew audit --strict <formula>
(after doingbrew install --build-from-source <formula>
)? If this is a new formula, does it passbrew audit --new <formula>
?Add system ld search paths by including dd system
/etc/ld.so.conf
.Before:
After: