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

QGIS 3.28.1 + scikit-learn causes QH6259 qhull internal error on Linux #284

Closed
1 task done
danschef opened this issue Dec 16, 2022 · 18 comments
Closed
1 task done
Labels

Comments

@danschef
Copy link

danschef commented Dec 16, 2022

Solution to issue cannot be found in the documentation.

  • I checked the documentation.

Issue

I just installed QGIS 3.28.1 (py311h7bb8ebf_2) together with scikit-learn 1.2.0 (py311h67c5ca5_0) into the same environment on Linux (Ubuntu 20.04). QGIS starts, but as soon as scikit-learn is imported, QGIS crashes and prints the the following message on the command line:

QH6249 qh_lib_check: Incorrect qhull library called.  Size of qhT for caller is 8752, but for qhull library is 8768.
QH6259 qhull internal error (qh_lib_check): Cannot continue due to QH6249.  'qhull_r 8.0.2 (2020.2.r 2020/08/31)' is not reentrant (e.g., qhull.so) or out-of-date.  Exit with 49
QGIS died on signal 11Aborted

This happens with all Python>=3.9 environments on Linux but works properly in the same setup on Windows or also on Linux with QGIS 3.22.11 (py310heaafcf0_0).

It can be reproduced with mamba create -n qgis_sklearn "qgis=3.28.1" scikit-learn.

Installed packages

# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
alsa-lib                  1.2.8                h166bdaf_0    conda-forge
attr                      2.5.1                h166bdaf_1    conda-forge
blosc                     1.21.3               hafa529b_0    conda-forge
boost-cpp                 1.78.0               h75c5d50_1    conda-forge
brotlipy                  0.7.0           py311hd4cff14_1005    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
c-ares                    1.18.1               h7f98852_0    conda-forge
ca-certificates           2022.12.7            ha878542_0    conda-forge
cairo                     1.16.0            ha61ee94_1014    conda-forge
certifi                   2022.12.7          pyhd8ed1ab_0    conda-forge
cffi                      1.15.1          py311h409f033_3    conda-forge
cfitsio                   4.2.0                hd9d235c_0    conda-forge
charset-normalizer        2.1.1              pyhd8ed1ab_0    conda-forge
coverage                  6.5.0           py311hd4cff14_1    conda-forge
cryptography              38.0.4          py311hb3c386c_0    conda-forge
curl                      7.86.0               h7bff187_1    conda-forge
dbus                      1.13.6               h5008d03_3    conda-forge
draco                     1.5.5                h924138e_0    conda-forge
eigen                     3.4.0                h4bd325d_0    conda-forge
exiv2                     0.27.5               h848de5d_0    conda-forge
expat                     2.5.0                h27087fc_0    conda-forge
fftw                      3.3.10          nompi_hf0379b8_106    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 hab24e00_0    conda-forge
fontconfig                2.14.1               hc2a2eb6_0    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
freetype                  2.12.1               hca18f0e_1    conda-forge
freexl                    1.0.6                h166bdaf_1    conda-forge
future                    0.18.2             pyhd8ed1ab_6    conda-forge
gdal                      3.6.0           py311hf6158c2_7    conda-forge
geos                      3.11.1               h27087fc_0    conda-forge
geotiff                   1.7.1                ha76d385_4    conda-forge
gettext                   0.21.1               h27087fc_0    conda-forge
giflib                    5.2.1                h36c2ea0_2    conda-forge
glib                      2.74.1               h6239696_1    conda-forge
glib-tools                2.74.1               h6239696_1    conda-forge
gsl                       2.7                  he838d99_0    conda-forge
gst-plugins-base          1.21.2               h3e40eee_0    conda-forge
gstreamer                 1.21.2               hd4edc92_0    conda-forge
gstreamer-orc             0.4.33               h166bdaf_0    conda-forge
hdf4                      4.2.15               h9772cbc_5    conda-forge
hdf5                      1.12.2          nompi_h2386368_100    conda-forge
httplib2                  0.21.0             pyhd8ed1ab_0    conda-forge
icu                       70.1                 h27087fc_0    conda-forge
idna                      3.4                pyhd8ed1ab_0    conda-forge
jack                      1.9.21               h583fa2b_2    conda-forge
jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
joblib                    1.2.0              pyhd8ed1ab_0    conda-forge
jpeg                      9e                   h166bdaf_2    conda-forge
json-c                    0.16                 hc379101_0    conda-forge
kealib                    1.4.15               ha7026e8_1    conda-forge
keyutils                  1.6.1                h166bdaf_0    conda-forge
krb5                      1.19.3               h3790be6_0    conda-forge
lame                      3.100             h166bdaf_1003    conda-forge
laz-perf                  3.0.0                h4bd325d_0    conda-forge
lcms2                     2.14                 h6ed2654_0    conda-forge
ld_impl_linux-64          2.39                 hcc3a1bd_1    conda-forge
lerc                      4.0.0                h27087fc_0    conda-forge
libblas                   3.9.0           16_linux64_openblas    conda-forge
libcap                    2.66                 ha37c62d_0    conda-forge
libcblas                  3.9.0           16_linux64_openblas    conda-forge
libclang                  15.0.6          default_h2e3cab8_0    conda-forge
libclang13                15.0.6          default_h3a83d3e_0    conda-forge
libcups                   2.3.3                h3e49a29_2    conda-forge
libcurl                   7.86.0               h7bff187_1    conda-forge
libdb                     6.2.32               h9c3ff4c_0    conda-forge
libdeflate                1.14                 h166bdaf_0    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libev                     4.33                 h516909a_1    conda-forge
libevent                  2.1.10               h9b69904_4    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libflac                   1.4.2                h27087fc_0    conda-forge
libgcc-ng                 12.2.0              h65d4601_19    conda-forge
libgcrypt                 1.10.1               h166bdaf_0    conda-forge
libgdal                   3.6.0                ha189470_7    conda-forge
libgfortran-ng            12.2.0              h69a702a_19    conda-forge
libgfortran5              12.2.0              h337968e_19    conda-forge
libglib                   2.74.1               h606061b_1    conda-forge
libgomp                   12.2.0              h65d4601_19    conda-forge
libgpg-error              1.45                 hc0c96e0_0    conda-forge
libiconv                  1.17                 h166bdaf_0    conda-forge
libkml                    1.3.0             h37653c0_1015    conda-forge
liblapack                 3.9.0           16_linux64_openblas    conda-forge
libllvm15                 15.0.6               h63197d8_0    conda-forge
libnetcdf                 4.8.1           nompi_h261ec11_106    conda-forge
libnghttp2                1.47.0               hdcd2b5c_1    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libogg                    1.3.4                h7f98852_1    conda-forge
libopenblas               0.3.21          pthreads_h78a6416_3    conda-forge
libopus                   1.3.1                h7f98852_1    conda-forge
libpng                    1.6.39               h753d276_0    conda-forge
libpq                     14.5                 h72a31a5_3    conda-forge
libprotobuf               3.21.12              h3eb15da_0    conda-forge
librttopo                 1.1.0               ha49c73b_12    conda-forge
libsecret                 0.18.8               h329b89f_2    conda-forge
libsndfile                1.1.0                hcb278e6_1    conda-forge
libspatialindex           1.9.3                h9c3ff4c_4    conda-forge
libspatialite             5.0.1               h7c8129e_22    conda-forge
libsqlite                 3.40.0               h753d276_0    conda-forge
libssh2                   1.10.0               haa6b8db_3    conda-forge
libstdcxx-ng              12.2.0              h46fd767_19    conda-forge
libsystemd0               252                  h2a991cd_0    conda-forge
libtiff                   4.4.0                h55922b4_4    conda-forge
libtool                   2.4.6             h9c3ff4c_1008    conda-forge
libudev1                  252                  h166bdaf_0    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libvorbis                 1.3.7                h9c3ff4c_0    conda-forge
libwebp                   1.2.4                h522a892_0    conda-forge
libwebp-base              1.2.4                h166bdaf_0    conda-forge
libxcb                    1.13              h7f98852_1004    conda-forge
libxkbcommon              1.0.3                he3ba5ed_0    conda-forge
libxml2                   2.10.3               h7463322_0    conda-forge
libxslt                   1.1.37               h873f0b0_0    conda-forge
libzip                    1.9.2                hc869a4a_1    conda-forge
libzlib                   1.2.13               h166bdaf_4    conda-forge
lz4-c                     1.9.3                h9c3ff4c_1    conda-forge
markupsafe                2.1.1           py311hd4cff14_2    conda-forge
mock                      4.0.3              pyhd8ed1ab_4    conda-forge
mpg123                    1.31.1               h27087fc_0    conda-forge
mysql-common              8.0.31               haf5c9bc_0    conda-forge
mysql-libs                8.0.31               h28c427c_0    conda-forge
ncurses                   6.3                  h27087fc_1    conda-forge
nitro                     2.7.dev6             h27087fc_5    conda-forge
nose2                     0.9.2                      py_0    conda-forge
nspr                      4.35                 h27087fc_0    conda-forge
nss                       3.82                 he02c5a1_0    conda-forge
numpy                     1.23.5          py311h7d28db0_0    conda-forge
openjpeg                  2.5.0                h7d73246_1    conda-forge
openssl                   1.1.1s               h0b41bf4_1    conda-forge
owslib                    0.27.2             pyhd8ed1ab_1    conda-forge
packaging                 22.0               pyhd8ed1ab_0    conda-forge
pcre2                     10.40                hc3806b6_0    conda-forge
pdal                      2.4.3                hbf2fe72_3    conda-forge
pip                       22.3.1             pyhd8ed1ab_0    conda-forge
pixman                    0.40.0               h36c2ea0_0    conda-forge
plotly                    5.11.0             pyhd8ed1ab_1    conda-forge
ply                       3.11                       py_1    conda-forge
poppler                   22.11.0              h92391eb_0    conda-forge
poppler-data              0.4.11               hd8ed1ab_0    conda-forge
postgresql                14.5                 h5bbe9e2_3    conda-forge
proj                      9.1.0                h93bde94_0    conda-forge
psycopg2                  2.9.3           py311hd4cff14_1    conda-forge
pthread-stubs             0.4               h36c2ea0_1001    conda-forge
pulseaudio                16.1                 h4a94279_0    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pygments                  2.13.0             pyhd8ed1ab_0    conda-forge
pyopenssl                 22.1.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.9              pyhd8ed1ab_0    conda-forge
pyproj                    3.4.1           py311h7c961c7_0    conda-forge
pyqt                      5.15.7          py311h3408d8f_2    conda-forge
pyqt5-sip                 12.11.0         py311ha362b79_2    conda-forge
pyqtwebkit                5.15.7          py311h3408d8f_3    conda-forge
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
python                    3.11.0          h582c2e5_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python_abi                3.11                    3_cp311    conda-forge
pytz                      2022.6             pyhd8ed1ab_0    conda-forge
pyyaml                    6.0             py311hd4cff14_5    conda-forge
qca                       2.3.5                h51e5271_0    conda-forge
qgis                      3.28.1          py311h7bb8ebf_2    conda-forge
qhull                     2020.2               h4bd325d_2    conda-forge
qjson                     0.9.0             h51e5271_1007    conda-forge
qscintilla2               2.13.3          py311h3408d8f_4    conda-forge
qt-main                   5.15.6               h7acdfc8_2    conda-forge
qtkeychain                0.13.2               h1601faa_0    conda-forge
qtwebkit                  5.212                h3383a02_6    conda-forge
qwt                       6.2.0                h1d9fb53_4    conda-forge
readline                  8.1.2                h0f457ee_0    conda-forge
requests                  2.28.1             pyhd8ed1ab_1    conda-forge
scikit-learn              1.2.0           py311h67c5ca5_0    conda-forge
scipy                     1.9.3           py311h69910c8_2    conda-forge
setuptools                65.5.1             pyhd8ed1ab_0    conda-forge
sip                       6.7.5           py311ha362b79_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
snappy                    1.1.9                hbd366e4_2    conda-forge
sqlite                    3.40.0               h4ff8645_0    conda-forge
tenacity                  8.1.0              pyhd8ed1ab_0    conda-forge
threadpoolctl             3.1.0              pyh8a188c0_0    conda-forge
tiledb                    2.11.3               h1e4a385_1    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
toml                      0.10.2             pyhd8ed1ab_0    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
tzcode                    2022g                h166bdaf_0    conda-forge
tzdata                    2022g                h191b570_0    conda-forge
urllib3                   1.26.13            pyhd8ed1ab_0    conda-forge
wheel                     0.38.4             pyhd8ed1ab_0    conda-forge
xcb-util                  0.4.0                h516909a_0    conda-forge
xcb-util-image            0.4.0                h166bdaf_0    conda-forge
xcb-util-keysyms          0.4.0                h516909a_0    conda-forge
xcb-util-renderutil       0.3.9                h166bdaf_0    conda-forge
xcb-util-wm               0.4.1                h516909a_0    conda-forge
xerces-c                  3.2.4                h55805fa_1    conda-forge
xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
xorg-libice               1.0.10               h7f98852_0    conda-forge
xorg-libsm                1.2.3             hd9c2040_1000    conda-forge
xorg-libx11               1.7.2                h7f98852_0    conda-forge
xorg-libxau               1.0.9                h7f98852_0    conda-forge
xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
xorg-libxext              1.3.4                h7f98852_1    conda-forge
xorg-libxrender           0.9.10            h7f98852_1003    conda-forge
xorg-renderproto          0.11.1            h7f98852_1002    conda-forge
xorg-xextproto            7.3.0             h7f98852_1002    conda-forge
xorg-xproto               7.0.31            h7f98852_1007    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge
yaml                      0.2.5                h7f98852_2    conda-forge
zlib                      1.2.13               h166bdaf_4    conda-forge
zstd                      1.5.2                h6239696_4    conda-forge

Environment info

active environment : qgis_sklearn
    active env location : /home/me/mambaforge/envs/qgis_sklearn
            shell level : 4
       user config file : /home/me/.condarc
 populated config files : /home/me/mambaforge/.condarc
                          /home/me/.condarc
          conda version : 22.9.0
    conda-build version : not installed
         python version : 3.10.8.final.0
       virtual packages : __linux=5.4.0=0
                          __glibc=2.31=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /home/me/mambaforge  (writable)
      conda av data dir : /home/me/mambaforge/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/me/mambaforge/pkgs
                          /home/me/.conda/pkgs
       envs directories : /home/me/mambaforge/envs
                          /home/me/.conda/envs
               platform : linux-64
             user-agent : conda/22.9.0 requests/2.28.1 CPython/3.10.8 Linux/5.4.0-52-generic ubuntu/20.04.5 glibc/2.31
                UID:GID : 1009:38755
             netrc file : None
           offline mode : False
@danschef danschef added the bug label Dec 16, 2022
@gillins
Copy link
Contributor

gillins commented Dec 17, 2022

Also when importing running from scipy.spatial import Delaunay. Could be since this commit in GDAL: conda-forge/gdal-feedstock@b3bd22d ?

I know scipy has internal version which maybe now conflicts?

@danschef
Copy link
Author

Sounds like this might be more an issue between gdal and scipy. Scikit-learn depends on scipy, so probably, it also runs from scipy.spatial import Delaunay. However, I cannot reproduce it on the command line with an environment that only has gdal and scipy in it (mamba create -n gdal_scipy "gdal=3.6" scipy), only QGIS crashes when I run the import from the Python console within QGIS. Not sure why it works on the command line.

@SrNetoChan
Copy link
Contributor

Maybe @rouault have some idea?

@rouault
Copy link

rouault commented Dec 17, 2022

I know scipy has internal version which maybe now conflicts?

ah, if scipy has an internal version of qhull, and it doesn't rename symbols, then yes, that's likely the cause of the issue.
Before conda-forge/gdal-feedstock@b3bd22d , GDAL used its internal copy, but when doing so, it does a lot of not-pretty-but-working #define tricks to avoid internal qhull symbols to leak outside of GDAL: https://github.com/OSGeo/gdal/blob/master/alg/internal_qhull_headers.h
So I'd say:

  • long term: scipy to use such internal renaming tricks, or offer the possibility to use an external libqhull
  • short term: perhaps revert conda-forge/gdal-feedstock@b3bd22d ? This commit is not critical. I thought it was cleaner to use the packaged qhull rather than the internal copy in GDAL

rouault added a commit to rouault/gdal-feedstock that referenced this issue Dec 17, 2022
This reverts commit b3bd22d
because of an issue when using gdal and scipy.spatial.Delaunay, the
later apparently bundling qhull.
See conda-forge/qgis-feedstock#284 (comment)
for details
@rouault
Copy link

rouault commented Dec 17, 2022

Revert of qhull dependency for GDAL proposed in conda-forge/gdal-feedstock#705

@danschef
Copy link
Author

Revert of qhull dependency for GDAL proposed in conda-forge/gdal-feedstock#705

Thanks, @rouault, I guess this should fix it as soon as qgis is compatible with gdal 3.6.1. Currently, I get this when attempting to update gdal to 3.6.1:

Could not solve for environment specs
Encountered problems while solving:
  - package pdal-2.4.3-hbf2fe72_3 requires tiledb >=2.11.3,<2.12.0a0, but none of the providers can be installed

@SrNetoChan
Copy link
Contributor

I guess that many other dependencies need to be rebuilt to use gdal 3.6.1 before we can build qgis itself

@danschef
Copy link
Author

The fastest solution would be to backport conda-forge/gdal-feedstock#705 to gdal 3.6.0, right? Not sure if this is possible.

@SrNetoChan
Copy link
Contributor

On the other hand, 3.6.0 has a nasty bug with geopackages, so would be better to really bump gdal to 3.6.1 in qgis

@gillins
Copy link
Contributor

gillins commented Dec 18, 2022

ah, if scipy has an internal version of qhull, and it doesn't rename symbols, then yes, that's likely the cause of the issue.

Thanks for looking at this @rouault . I guess ATM anything that links to qhull will likely be incompatible with scipy which isn't great...

@rouault
Copy link

rouault commented Dec 18, 2022

I guess ATM anything that links to qhull will likely be incompatible with scipy which isn't great...

yes, most likely. There is nothing GDAL specific in that crash. The fact that it happens in a QGIS context and not in simpler scenarios is typically of symbol clashes where the order of symbol loading is somewhat "random", and sometimes you're lucky, sometimes not.

@danschef
Copy link
Author

On the other hand, 3.6.0 has a nasty bug with geopackages, so would be better to really bump gdal to 3.6.1 in qgis

Right, but at the moment, any QGIS plugin, that directly or indirectly depends on scipy, will crash QGIS. So far as I understand from the release notes of gdal 3.6.1, setting OGR_GPKG_ALLOW_THREADED_RTREE=NO would fix the issue there.

@SrNetoChan
Copy link
Contributor

I am ok rebuilding qgis with a gdal 3.6.0 patched version, but since 3.6.1 is already out, I will make sure to rebuild it for that version as well as soon as possible.

Geopackage is QGIS default format, which means it will impact most of our user. Although there's a workaround, most folks won't know about it, so better fix it as soon as possible.

@rouault
Copy link

rouault commented Jan 8, 2023

looks like this issue could be closed

@gillins
Copy link
Contributor

gillins commented Jan 9, 2023

Indeed. FYI did submit this to the scipy-dev mailing list (https://mail.python.org/archives/list/scipy-dev@python.org/thread/I535LGRTWUXJIP2VM7VQGF3HELHQJ4B2/). I'll post back here with how it got resolved.

@gillins gillins closed this as completed Jan 9, 2023
@gillins
Copy link
Contributor

gillins commented Jan 16, 2023

Just FYI, turns out that scipy does implement symbol hiding for these symbols (and those from other vendored libs) on Linux when built using Meson. However, conda-forge still uses distutils for reasons detailed here: conda-forge/scipy-feedstock#213 and distutils builds don't implement symbol hiding.
This doesn't appear to be an issue on OSX - apparently due to differences in the symbol resolution logic but I don't have access to an OSX machine to check in more detail. On Windows symbols aren't exported by default so this is likely to be a Linux specific issue.

So, turns out it is hard to get a consistent software stack!

@rouault scipy (with Meson) uses the --version-script option to the GNU linker to control symbol visibility, not sure if this is an option for vendored libs within gdal? I guess this might not be so easy to implement with cmake?

@rgommers
Copy link

However, conda-forge still uses distutils for reasons detailed here: conda-forge/scipy-feedstock#213 and distutils builds don't implement symbol hiding.

Switching to Meson for anything but Windows is quite straightforward by now though, and can be done either now or for SciPy 1.10.1.

@rouault
Copy link

rouault commented Jan 16, 2023

@rouault scipy (with Meson) uses the --version-script option to the GNU linker to control symbol visibility, not sure if this is an option for vendored libs within gdal? I guess this might not be so easy to implement with cmake?

I've tried to avoid linker specific solutions for symbol hiding. What I do is that using objdump I establish the list of symbols of the vendored library and then generate a header file with a list of "#define symbol_in_the_vendored_lib gdal_symbol_in_the_vendored_lib". Fully cross platform.
Example with libtiff:

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

No branches or pull requests

5 participants