Skip to content

Commit

Permalink
Fix numpy issue libstdc++.so.6 not found (pytorch#3080)
Browse files Browse the repository at this point in the history
Summary:
X-link: facebookresearch/FBGEMM#175

Pull Request resolved: pytorch#3080

`numpy` package on `conda-forge` causes error:
```
/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found
```
Remove installation from `conda` and let it be installed by `pip`.
https://github.com/pytorch/FBGEMM/actions/runs/10712252806/job/29702380694

Full error below:
```
Please note and check the following:

  * The Python version is: Python3.9 from "/__w/_temp/conda_environment_10708405243/bin/python"
  * The NumPy version is: "2.0.0"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /__w/_temp/conda_environment_10708405243/lib/python3.9/site-packages/numpy/_core/_multiarray_umath.cpython-39-x86_64-linux-gnu.so)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/__w/FBGEMM/FBGEMM/pytorch/FBGEMM/fbgemm_gpu/setup.py", line 21, in <module>
    import torch
  File "/__w/_temp/conda_environment_10708405243/lib/python3.9/site-packages/torch/__init__.py", line 1707, in <module>
    from torch import storage as storage  # usort: skip
  File "/__w/_temp/conda_environment_10708405243/lib/python3.9/site-packages/torch/storage.py", line 23, in <module>
    import numpy as np
  File "/__w/_temp/conda_environment_10708405243/lib/python3.9/site-packages/numpy/__init__.py", line 119, in <module>
    raise ImportError(msg) from e
ImportError: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
```

https://github.com/pytorch/FBGEMM/actions/runs/10708405243/job/29690649284

Reviewed By: q10, sryap

Differential Revision: D62210034

fbshipit-source-id: 447fe0b53843bb01779a335b8c13cca7eb42d0ae
  • Loading branch information
spcyppt authored and facebook-github-bot committed Sep 5, 2024
1 parent c1a98f0 commit 75ac3c0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .github/scripts/fbgemm_gpu_build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,12 @@ __build_fbgemm_gpu_common_pre_steps () {
# permit for this
__build_fbgemm_gpu_set_run_multicore

# Check LD_LIBRARY_PATH for numpy
echo "[CHECK] LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}"

echo "[BUILD] Running pre-build cleanups ..."
print_exec rm -rf dist

# shellcheck disable=SC2086
print_exec conda run --no-capture-output ${env_prefix} python setup.py clean

Expand Down
14 changes: 12 additions & 2 deletions .github/scripts/utils_build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ __conda_install_glibc () {
echo "[INSTALL] Installing GLIBC (architecture = ${archname}) ..."
# shellcheck disable=SC2086
(exec_with_retries 3 conda install ${env_prefix} -c conda-forge -y "sysroot_linux-${archname}"=2.17) || return 1

echo "[CHECK] LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}"
# Ensure libstdc++.so.6 is found
# shellcheck disable=SC2153
if [ "${CONDA_PREFIX}" == '' ]; then
echo "[CHECK] CONDA_PREFIX is not set."
(test_filepath "${env_name}" 'libstdc++.so.6') || return 1
else
(test_filepath "${CONDA_PREFIX}" 'libstdc++.so.6') || return 1
fi

}

__set_glibcxx_preload () {
Expand Down Expand Up @@ -285,7 +296,6 @@ install_build_tools () {
make \
ncurses \
ninja \
numpy \
openblas \
scikit-build \
wheel) || return 1
Expand All @@ -305,7 +315,7 @@ install_build_tools () {
(test_binpath "${env_name}" ninja) || return 1

# Check Python packages are importable
local import_tests=( click hypothesis jinja2 numpy skbuild wheel )
local import_tests=( click hypothesis jinja2 skbuild wheel )
for p in "${import_tests[@]}"; do
(test_python_import_package "${env_name}" "${p}") || return 1
done
Expand Down
2 changes: 1 addition & 1 deletion fbgemm_gpu/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ hypothesis
jinja2
mpmath==1.3.0
ninja
numpy
numpy>=2.0.2
pyre-extensions
scikit-build
setuptools
Expand Down

0 comments on commit 75ac3c0

Please sign in to comment.