dmlc / xgboost

Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow
https://xgboost.readthedocs.io/en/stable/
Apache License 2.0
26.3k stars 8.73k forks source link

_is_cupy_array returning False for cupy arrays #8299

Closed beckernick closed 2 years ago

beckernick commented 2 years ago

As noted in https://github.com/rapidsai/cuml/issues/4903 , it appears that cupy arrays may not currently be passed the _is_cupy_array instance check, which can cause downstream errors.

from xgboost.compat import lazy_isinstance
from xgboost.data import _is_cupy_array
from xgboost._typing import DataType
import cupy as cp

arr = cp.array([1,2])
print(_is_cupy_array(arr))
print(lazy_isinstance(arr, "cupy", "ndarray"))

# copied directly from github
def copied_is_cupy_array(data: DataType) -> bool:
    return any(
        lazy_isinstance(data, n, "ndarray")
        for n in ("cupy.core.core", "cupy", "cupy._core.core")
    )

print(copied_is_cupy_array(arr))
False
True
True

Environment:

cupy                      11.1.0           py39hc3c280e_0    conda-forge
libxgboost                1.6.2dev.rapidsai22.10       cuda_11_0    rapidsai-nightly
py-xgboost                1.6.2dev.rapidsai22.10  cuda_11_py39_0    rapidsai-nightly
rapids-xgboost            22.10.00a221003 cuda11_py39_gf73d519_71    rapidsai-nightly
xgboost                   1.6.2dev.rapidsai22.10  cuda_11_py39_0    rapidsai-nightly

Full environment:

# packages in environment at /home/nicholasb/miniconda3/envs/rapids-22.10: # # Name Version Build Channel _libgcc_mutex 0.1 conda_forge conda-forge _openmp_mutex 4.5 2_gnu conda-forge aiohttp 3.8.3 py39hb9d737c_0 conda-forge aiosignal 1.2.0 pyhd8ed1ab_0 conda-forge anyio 3.6.1 py39hf3d152e_0 conda-forge aom 3.5.0 h27087fc_0 conda-forge appdirs 1.4.4 pyh9f0ad1d_0 conda-forge argon2-cffi 21.3.0 pyhd8ed1ab_0 conda-forge argon2-cffi-bindings 21.2.0 py39hb9d737c_2 conda-forge arrow-cpp 9.0.0 py39hd3ccb9b_2_cpu conda-forge asttokens 2.0.8 pyhd8ed1ab_0 conda-forge async-timeout 4.0.2 pyhd8ed1ab_0 conda-forge attrs 22.1.0 pyh71513ae_1 conda-forge aws-c-cal 0.5.11 h95a6274_0 conda-forge aws-c-common 0.6.2 h7f98852_0 conda-forge aws-c-event-stream 0.2.7 h3541f99_13 conda-forge aws-c-io 0.10.5 hfb6a706_0 conda-forge aws-checksums 0.1.11 ha31a3da_7 conda-forge aws-sdk-cpp 1.8.186 hb4091e7_3 conda-forge babel 2.10.3 pyhd8ed1ab_0 conda-forge backcall 0.2.0 pyh9f0ad1d_0 conda-forge backports 1.0 py_2 conda-forge backports.functools_lru_cache 1.6.4 pyhd8ed1ab_0 conda-forge beautifulsoup4 4.11.1 pyha770c72_0 conda-forge bleach 5.0.1 pyhd8ed1ab_0 conda-forge blosc 1.21.1 h83bc5f7_3 conda-forge bokeh 2.4.3 py39hf3d152e_0 conda-forge boost 1.78.0 py39hac2352c_0 conda-forge boost-cpp 1.78.0 h75c5d50_1 conda-forge branca 0.5.0 pyhd8ed1ab_0 conda-forge brotli 1.0.9 h166bdaf_7 conda-forge brotli-bin 1.0.9 h166bdaf_7 conda-forge brotlipy 0.7.0 py39hb9d737c_1004 conda-forge brunsli 0.1 h9c3ff4c_0 conda-forge bzip2 1.0.8 h7f98852_4 conda-forge c-ares 1.18.1 h7f98852_0 conda-forge c-blosc2 2.4.2 h7a311fb_0 conda-forge ca-certificates 2022.9.24 ha878542_0 conda-forge cachetools 5.2.0 pyhd8ed1ab_0 conda-forge cairo 1.16.0 ha61ee94_1014 conda-forge certifi 2022.9.24 pyhd8ed1ab_0 conda-forge cffi 1.15.1 py39he91dace_0 conda-forge cfitsio 4.1.0 hd9d235c_0 conda-forge charls 2.3.4 h9c3ff4c_0 conda-forge charset-normalizer 2.1.1 pyhd8ed1ab_0 conda-forge click 8.1.3 py39hf3d152e_0 conda-forge click-plugins 1.1.1 py_0 conda-forge cligj 0.7.2 pyhd8ed1ab_1 conda-forge cloudpickle 2.2.0 pyhd8ed1ab_0 conda-forge colorama 0.4.5 pyhd8ed1ab_0 conda-forge colorcet 3.0.0 pyhd8ed1ab_0 conda-forge contourpy 1.0.5 py39hf939315_0 conda-forge cryptography 37.0.4 py39hd97740a_0 conda-forge cucim 22.10.00a221003 cuda_11_py39_gf4229e3_51 rapidsai-nightly cuda-python 11.7.0 py39h3fd9d12_0 nvidia cudatoolkit 11.5.0 h36ae40a_9 nvidia cudf 22.10.00a220929 cuda_11_py39_g5fad28942e_286 rapidsai-nightly cudf_kafka 22.10.00a220929 py39_g920b58f948_288 rapidsai-nightly cugraph 22.10.0a0+101.g83f27a1b.dirty pypi_0 pypi cuml 22.10.00a220930 cuda11_py39_g96da84cc1_50 rapidsai-nightly cupy 11.1.0 py39hc3c280e_0 conda-forge curl 7.83.1 h7bff187_0 conda-forge cusignal 22.10.00a221003 py39_gd075e87_12 rapidsai-nightly cuspatial 22.10.00a221003 py39_gba50335_58 rapidsai-nightly custreamz 22.10.00a220929 py39_g920b58f948_288 rapidsai-nightly cuxfilter 22.10.00a221003 py39_ge1aa0b2_17 rapidsai-nightly cycler 0.11.0 pyhd8ed1ab_0 conda-forge cyrus-sasl 2.1.27 h230043b_5 conda-forge cytoolz 0.12.0 py39hb9d737c_0 conda-forge dask 2022.7.1 pyhd8ed1ab_0 conda-forge dask-core 2022.7.1 pyhd8ed1ab_0 conda-forge dask-cuda 22.10.00a221003 py39_gc0ae66c_20 rapidsai-nightly dask-cudf 22.10.00a220929 cuda_11_py39_g920b58f948_288 rapidsai-nightly datashader 0.13.1a py_0 rapidsai-nightly datashape 0.5.4 py_1 conda-forge dav1d 1.0.0 h166bdaf_1 conda-forge debugpy 1.6.3 py39h5a03fae_0 conda-forge decorator 5.1.1 pyhd8ed1ab_0 conda-forge defusedxml 0.7.1 pyhd8ed1ab_0 conda-forge distributed 2022.7.1 pyhd8ed1ab_0 conda-forge dlpack 0.5 h9c3ff4c_0 conda-forge entrypoints 0.4 pyhd8ed1ab_0 conda-forge executing 1.1.0 pyhd8ed1ab_0 conda-forge expat 2.4.9 h27087fc_0 conda-forge faiss-proc 1.0.0 cuda conda-forge fastavro 1.6.1 py39hb9d737c_0 conda-forge fastrlock 0.8 py39h5a03fae_2 conda-forge fiona 1.8.21 py39h54775ec_2 conda-forge flit-core 3.7.1 pyhd8ed1ab_0 conda-forge folium 0.12.1.post1 pyhd8ed1ab_1 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.0 hc2a2eb6_1 conda-forge fonts-conda-ecosystem 1 0 conda-forge fonts-conda-forge 1 0 conda-forge fonttools 4.37.4 py39hb9d737c_0 conda-forge freetype 2.12.1 hca18f0e_0 conda-forge freexl 1.0.6 h166bdaf_1 conda-forge frozenlist 1.3.1 py39hb9d737c_0 conda-forge fsspec 2022.8.2 pyhd8ed1ab_0 conda-forge gdal 3.5.2 py39h92c1d47_3 conda-forge geopandas 0.11.1 pyhd8ed1ab_0 conda-forge geopandas-base 0.11.1 pyha770c72_0 conda-forge geos 3.11.0 h27087fc_0 conda-forge geotiff 1.7.1 h4fc65e6_3 conda-forge gettext 0.19.8.1 h27087fc_1009 conda-forge gflags 2.2.2 he1b5a44_1004 conda-forge giflib 5.2.1 h36c2ea0_2 conda-forge glog 0.6.0 h6f12383_0 conda-forge grpc-cpp 1.47.1 hbad87ad_6 conda-forge hdf4 4.2.15 h9772cbc_4 conda-forge hdf5 1.12.2 nompi_h2386368_100 conda-forge heapdict 1.0.1 py_0 conda-forge holoviews 1.14.6 pyhd8ed1ab_0 conda-forge icu 70.1 h27087fc_0 conda-forge idna 3.4 pyhd8ed1ab_0 conda-forge imagecodecs 2022.9.26 py39hf586f7a_0 conda-forge imageio 2.22.0 pyhfa7a67d_0 conda-forge importlib-metadata 4.11.4 py39hf3d152e_0 conda-forge importlib_resources 5.9.0 pyhd8ed1ab_0 conda-forge ipykernel 6.14.0 py39hef51801_0 conda-forge ipython 8.4.0 py39hf3d152e_0 conda-forge ipython_genutils 0.2.0 py_1 conda-forge ipywidgets 8.0.2 pyhd8ed1ab_1 conda-forge jbig 2.1 h7f98852_2003 conda-forge jedi 0.18.1 py39hf3d152e_1 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 json5 0.9.5 pyh9f0ad1d_0 conda-forge jsonschema 4.16.0 pyhd8ed1ab_0 conda-forge jupyter-server-proxy 3.2.2 pyhd8ed1ab_0 conda-forge jupyter_client 7.3.4 pyhd8ed1ab_0 conda-forge jupyter_core 4.11.1 py39hf3d152e_0 conda-forge jupyter_server 1.19.1 pyhd8ed1ab_0 conda-forge jupyterlab 3.4.7 pyhd8ed1ab_0 conda-forge jupyterlab_pygments 0.2.2 pyhd8ed1ab_0 conda-forge jupyterlab_server 2.15.2 pyhd8ed1ab_0 conda-forge jupyterlab_widgets 3.0.3 pyhd8ed1ab_0 conda-forge jxrlib 1.1 h7f98852_2 conda-forge kealib 1.4.15 ha7026e8_1 conda-forge keyutils 1.6.1 h166bdaf_0 conda-forge kiwisolver 1.4.4 py39hf939315_0 conda-forge krb5 1.19.3 h3790be6_0 conda-forge lcms2 2.12 hddcbb42_0 conda-forge ld_impl_linux-64 2.36.1 hea4e1c9_2 conda-forge lerc 4.0.0 h27087fc_0 conda-forge libabseil 20220623.0 cxx17_h48a1fff_4 conda-forge libaec 1.0.6 h9c3ff4c_0 conda-forge libavif 0.10.1 h5cdd6b5_2 conda-forge libblas 3.9.0 16_linux64_openblas conda-forge libbrotlicommon 1.0.9 h166bdaf_7 conda-forge libbrotlidec 1.0.9 h166bdaf_7 conda-forge libbrotlienc 1.0.9 h166bdaf_7 conda-forge libcblas 3.9.0 16_linux64_openblas conda-forge libcrc32c 1.1.2 h9c3ff4c_0 conda-forge libcucim 22.10.00a221003 cuda11_gf4229e3_51 rapidsai-nightly libcudf 22.10.00a220929 cuda11_g920b58f948_288 rapidsai-nightly libcudf_kafka 22.10.00a220929 g920b58f948_288 rapidsai-nightly libcugraph 22.10.00a221003 cuda11_gc72c44fa_102 rapidsai-nightly libcugraph_etl 22.10.00a221003 cuda11_gc72c44fa_102 rapidsai-nightly libcugraphops 22.10.00a221003 cuda11_g8078fdc_31 rapidsai-nightly libcuml 22.10.00a220930 cuda11_g96da84cc1_50 rapidsai-nightly libcumlprims 22.10.00a220804 cuda11_g2adfe69_0 rapidsai-nightly libcurl 7.83.1 h7bff187_0 conda-forge libcusolver 11.4.0.1 0 nvidia libcusparse 11.7.4.91 0 nvidia libcuspatial 22.10.00a221003 cuda11_gba50335_58 rapidsai-nightly libdap4 3.20.6 hd7c4107_2 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 libfaiss 1.7.0 cuda112h5bea7ad_8_cuda conda-forge libffi 3.4.2 h7f98852_5 conda-forge libgcc-ng 12.1.0 h8d9b700_16 conda-forge libgcrypt 1.10.1 h166bdaf_0 conda-forge libgdal 3.5.2 hc23bfc3_3 conda-forge libgfortran-ng 12.1.0 h69a702a_16 conda-forge libgfortran5 12.1.0 hdcd56e2_16 conda-forge libglib 2.74.0 h7a41b64_0 conda-forge libgomp 12.1.0 h8d9b700_16 conda-forge libgoogle-cloud 2.1.0 h9ebe8e8_2 conda-forge libgpg-error 1.45 hc0c96e0_0 conda-forge libgsasl 1.10.0 h5b4c23d_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 libllvm11 11.1.0 he0ac6c6_4 conda-forge libnetcdf 4.8.1 nompi_h21705cb_104 conda-forge libnghttp2 1.47.0 hdcd2b5c_1 conda-forge libnsl 2.0.0 h7f98852_0 conda-forge libntlm 1.4 h7f98852_1002 conda-forge libopenblas 0.3.21 pthreads_h78a6416_3 conda-forge libpng 1.6.38 h753d276_0 conda-forge libpq 14.5 hd77ab85_0 conda-forge libprotobuf 3.20.1 h6239696_4 conda-forge libraft-distance 22.10.00a221001 cuda11_g2bd8d042_61 rapidsai-nightly libraft-headers 22.10.00a221001 cuda11_g2bd8d042_61 rapidsai-nightly libraft-nn 22.10.00a221001 cuda11_g2bd8d042_61 rapidsai-nightly librdkafka 1.7.0 hc49e61c_1 conda-forge librmm 22.10.00a220930 cuda11_g8a3a552e_28 rapidsai-nightly librttopo 1.1.0 hf730bdb_11 conda-forge libsodium 1.0.18 h36c2ea0_1 conda-forge libspatialindex 1.9.3 h9c3ff4c_4 conda-forge libspatialite 5.0.1 h38b5f51_18 conda-forge libsqlite 3.39.4 h753d276_0 conda-forge libssh2 1.10.0 haa6b8db_3 conda-forge libstdcxx-ng 12.1.0 ha89aaad_16 conda-forge libthrift 0.16.0 h491838f_2 conda-forge libtiff 4.4.0 h55922b4_4 conda-forge libutf8proc 2.7.0 h7f98852_0 conda-forge libuuid 2.32.1 h7f98852_1000 conda-forge libuv 1.44.2 h166bdaf_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 libxgboost 1.6.2dev.rapidsai22.10 cuda_11_0 rapidsai-nightly libxml2 2.9.14 h22db469_4 conda-forge libzip 1.9.2 hc869a4a_1 conda-forge libzlib 1.2.12 h166bdaf_4 conda-forge libzopfli 1.0.3 h9c3ff4c_0 conda-forge llvmlite 0.39.1 py39h7d9a04d_0 conda-forge locket 1.0.0 pyhd8ed1ab_0 conda-forge lz4 4.0.0 py39h029007f_2 conda-forge lz4-c 1.9.3 h9c3ff4c_1 conda-forge mapclassify 2.4.3 pyhd8ed1ab_0 conda-forge markdown 3.4.1 pyhd8ed1ab_0 conda-forge markupsafe 2.1.1 py39hb9d737c_1 conda-forge matplotlib-base 3.6.0 py39hf9fd14e_0 conda-forge matplotlib-inline 0.1.6 pyhd8ed1ab_0 conda-forge mistune 2.0.4 pyhd8ed1ab_0 conda-forge msgpack-python 1.0.4 py39hf939315_0 conda-forge multidict 6.0.2 py39hb9d737c_1 conda-forge multipledispatch 0.6.0 py_0 conda-forge munch 2.5.0 py_0 conda-forge munkres 1.1.4 pyh9f0ad1d_0 conda-forge nbclassic 0.4.4 pyhd8ed1ab_0 conda-forge nbclient 0.6.8 pyhd8ed1ab_0 conda-forge nbconvert 7.1.0 pyhd8ed1ab_0 conda-forge nbconvert-core 7.1.0 pyhd8ed1ab_0 conda-forge nbconvert-pandoc 7.1.0 pyhd8ed1ab_0 conda-forge nbformat 5.6.1 pyhd8ed1ab_0 conda-forge nccl 2.14.3.1 h0800d71_0 conda-forge ncurses 6.3 h27087fc_1 conda-forge nest-asyncio 1.5.6 pyhd8ed1ab_0 conda-forge networkx 2.6.3 pyhd8ed1ab_1 conda-forge nodejs 18.10.0 h96d913c_0 conda-forge notebook 6.4.12 pyha770c72_0 conda-forge notebook-shim 0.1.0 pyhd8ed1ab_0 conda-forge nspr 4.32 h9c3ff4c_1 conda-forge nss 3.78 h2350873_0 conda-forge numba 0.56.2 py39h61ddf18_1 conda-forge numpy 1.21.6 py39h18676bf_0 conda-forge nvtx 0.2.3 py39h3811e60_1 conda-forge openjpeg 2.5.0 h7d73246_1 conda-forge openssl 1.1.1q h166bdaf_0 conda-forge orc 1.7.6 h6c59b99_0 conda-forge packaging 21.3 pyhd8ed1ab_0 conda-forge pandas 1.5.0 py39h4661b88_0 conda-forge pandoc 2.19.2 ha770c72_0 conda-forge pandocfilters 1.5.0 pyhd8ed1ab_0 conda-forge panel 0.12.7 pyhd8ed1ab_0 conda-forge param 1.12.2 pyh6c4a22f_0 conda-forge parquet-cpp 1.5.1 1 conda-forge parso 0.8.3 pyhd8ed1ab_0 conda-forge partd 1.3.0 pyhd8ed1ab_0 conda-forge pcre 8.45 h9c3ff4c_0 conda-forge pcre2 10.37 hc3806b6_1 conda-forge pexpect 4.8.0 pyh9f0ad1d_2 conda-forge pickleshare 0.7.5 py39hde42818_1002 conda-forge pillow 9.2.0 py39hd5dbb17_2 conda-forge pip 22.2.2 pyhd8ed1ab_0 conda-forge pixman 0.40.0 h36c2ea0_0 conda-forge pkgutil-resolve-name 1.3.10 pyhd8ed1ab_0 conda-forge poppler 22.04.0 h0733791_3 conda-forge poppler-data 0.4.11 hd8ed1ab_0 conda-forge postgresql 14.5 hfdbbde3_0 conda-forge proj 9.0.1 h93bde94_1 conda-forge prometheus_client 0.14.1 pyhd8ed1ab_0 conda-forge prompt-toolkit 3.0.31 pyha770c72_0 conda-forge protobuf 3.20.1 py39h5a03fae_0 conda-forge psutil 5.9.2 py39hb9d737c_0 conda-forge pthread-stubs 0.4 h36c2ea0_1001 conda-forge ptxcompiler 0.6.0 cuda_11_py39_g455bc7f_2 rapidsai-nightly ptyprocess 0.7.0 pyhd3deb0d_0 conda-forge pure_eval 0.2.2 pyhd8ed1ab_0 conda-forge py-xgboost 1.6.2dev.rapidsai22.10 cuda_11_py39_0 rapidsai-nightly pyarrow 9.0.0 py39hc0775d8_2_cpu conda-forge pycparser 2.21 pyhd8ed1ab_0 conda-forge pyct 0.4.6 py_0 conda-forge pyct-core 0.4.6 py_0 conda-forge pydeck 0.5.0 pyh9f0ad1d_0 conda-forge pyee 8.1.0 pyhd8ed1ab_0 conda-forge pygments 2.13.0 pyhd8ed1ab_0 conda-forge pylibcugraph 22.10.00a221003 cuda11_py39_gc72c44fa_102 rapidsai-nightly pylibraft 22.10.00a221001 cuda11_py39_g2bd8d042_61 rapidsai-nightly pynvml 11.4.1 pyhd8ed1ab_0 conda-forge pyopenssl 22.0.0 pyhd8ed1ab_1 conda-forge pyparsing 3.0.9 pyhd8ed1ab_0 conda-forge pyppeteer 1.0.2 pyhd8ed1ab_0 conda-forge pyproj 3.4.0 py39hdcf6798_0 conda-forge pyrsistent 0.18.1 py39hb9d737c_1 conda-forge pysocks 1.7.1 py39hf3d152e_5 conda-forge python 3.9.13 h9a8a25e_0_cpython conda-forge python-confluent-kafka 1.7.0 py39h3811e60_2 conda-forge python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python-fastjsonschema 2.16.2 pyhd8ed1ab_0 conda-forge python_abi 3.9 2_cp39 conda-forge pytz 2022.4 pyhd8ed1ab_0 conda-forge pyviz_comms 2.2.1 pyhd8ed1ab_1 conda-forge pywavelets 1.3.0 py39hd257fcd_1 conda-forge pyyaml 6.0 py39hb9d737c_4 conda-forge pyzmq 24.0.1 py39headdf64_0 conda-forge raft-dask 22.10.00a221001 cuda11_py39_g2bd8d042_61 rapidsai-nightly rapids 22.10.00a221003 cuda11_py39_gf73d519_71 rapidsai-nightly rapids-xgboost 22.10.00a221003 cuda11_py39_gf73d519_71 rapidsai-nightly re2 2022.06.01 h27087fc_0 conda-forge readline 8.1.2 h0f457ee_0 conda-forge requests 2.28.1 pyhd8ed1ab_1 conda-forge rmm 22.10.00a220930 cuda11_py39_g8a3a552e_28 rapidsai-nightly rtree 1.0.0 py39hb102c33_1 conda-forge s2n 1.0.10 h9b69904_0 conda-forge scikit-image 0.19.3 py39h1832856_1 conda-forge scikit-learn 1.1.2 py39he5e8d7e_0 conda-forge scipy 1.9.1 py39h8ba3f38_0 conda-forge send2trash 1.8.0 pyhd8ed1ab_0 conda-forge setuptools 60.10.0 py39hf3d152e_0 conda-forge shapely 1.8.4 py39h68ae834_0 conda-forge simpervisor 0.4 pyhd8ed1ab_0 conda-forge six 1.16.0 pyh6c4a22f_0 conda-forge snappy 1.1.9 hbd366e4_1 conda-forge sniffio 1.3.0 pyhd8ed1ab_0 conda-forge sortedcontainers 2.4.0 pyhd8ed1ab_0 conda-forge soupsieve 2.3.2.post1 pyhd8ed1ab_0 conda-forge spdlog 1.8.5 h4bd325d_1 conda-forge sqlite 3.39.4 h4ff8645_0 conda-forge stack_data 0.5.1 pyhd8ed1ab_0 conda-forge streamz 0.6.4 pyh6c4a22f_0 conda-forge strings_udf 22.10.00a220929 cuda_11_py39_g920b58f948_288 rapidsai-nightly tblib 1.7.0 pyhd8ed1ab_0 conda-forge terminado 0.15.0 py39hf3d152e_0 conda-forge threadpoolctl 3.1.0 pyh8a188c0_0 conda-forge tifffile 2022.8.12 pyhd8ed1ab_0 conda-forge tiledb 2.11.3 h1e4a385_0 conda-forge tinycss2 1.1.1 pyhd8ed1ab_0 conda-forge tk 8.6.12 h27826a3_0 conda-forge tomli 2.0.1 pyhd8ed1ab_0 conda-forge toolz 0.12.0 pyhd8ed1ab_0 conda-forge tornado 6.1 py39hb9d737c_3 conda-forge tqdm 4.64.1 pyhd8ed1ab_0 conda-forge traitlets 5.4.0 pyhd8ed1ab_0 conda-forge treelite 3.0.0 py39hc7ff369_0 conda-forge treelite-runtime 3.0.0 pypi_0 pypi typing-extensions 4.3.0 hd8ed1ab_0 conda-forge typing_extensions 4.3.0 pyha770c72_0 conda-forge tzcode 2022d h166bdaf_0 conda-forge tzdata 2022d h191b570_0 conda-forge ucx 1.13.1 h538f049_0 conda-forge ucx-proc 1.0.0 gpu rapidsai-nightly ucx-py 0.28.00a220927 py39_g2ab6070_27 rapidsai-nightly unicodedata2 14.0.0 py39hb9d737c_1 conda-forge urllib3 1.26.11 pyhd8ed1ab_0 conda-forge wcwidth 0.2.5 pyh9f0ad1d_2 conda-forge webencodings 0.5.1 py_1 conda-forge websocket-client 1.4.1 pyhd8ed1ab_0 conda-forge websockets 10.3 py39hb9d737c_0 conda-forge wheel 0.37.1 pyhd8ed1ab_0 conda-forge widgetsnbextension 4.0.3 pyhd8ed1ab_0 conda-forge xarray 2022.9.0 pyhd8ed1ab_0 conda-forge xerces-c 3.2.3 h55805fa_5 conda-forge xgboost 1.6.2dev.rapidsai22.10 cuda_11_py39_0 rapidsai-nightly 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 xyzservices 2022.9.0 pyhd8ed1ab_0 conda-forge xz 5.2.6 h166bdaf_0 conda-forge yaml 0.2.5 h7f98852_2 conda-forge yarl 1.7.2 py39hb9d737c_2 conda-forge zeromq 4.3.4 h9c3ff4c_1 conda-forge zfp 1.0.0 h27087fc_1 conda-forge zict 2.2.0 pyhd8ed1ab_0 conda-forge zipp 3.8.1 pyhd8ed1ab_0 conda-forge zlib 1.2.12 h166bdaf_4 conda-forge zlib-ng 2.0.6 h166bdaf_0 conda-forge zstd 1.5.2 h6239696_4 conda-forge
trivialfis commented 2 years ago

Looking at the packages, there are 2 xgboost packages, one from dmlc and another from rapids. Is is possible to remove the rapids-xgboost for now?

beckernick commented 2 years ago

Yes. When I create an environment with mamba create -n xgb-test -c conda-forge python=3.9 cudatoolkit=11.5 py-xgboost cupy, things work correctly and I get the following:

python
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:58:50) 
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from xgboost.compat import lazy_isinstance
>>> from xgboost.data import _is_cupy_array
>>> from xgboost._typing import DataType
>>> import cupy as cp
>>> 
>>> arr = cp.array([1,2])
>>> print(_is_cupy_array(arr))
True
>>> print(lazy_isinstance(arr, "cupy", "ndarray"))
True
>>> 
>>> # copied directly from github
>>> def copied_is_cupy_array(data: DataType) -> bool:
...     return any(
...         lazy_isinstance(data, n, "ndarray")
...         for n in ("cupy.core.core", "cupy", "cupy._core.core")
...     )
... 
>>> print(copied_is_cupy_array(arr))

The original environment is what comes by default in the current rapids nightly environment. If we need to tweak this, we can.

trivialfis commented 2 years ago

That's great news! I think the rapids-xgboost might be outdated (the recent cupy upgrade broke the _is_cupy_array function, which is fixed in the latest xgboost) and Python is confused when loading modules.

wbo4958 commented 2 years ago

May I ask what's the rapids-xgboost?

trivialfis commented 2 years ago

@wbo4958 This one https://github.com/rapidsai/xgboost . It's a fork of XGBoost managed by rapids for consistent releases.

wbo4958 commented 2 years ago

so, that is the source of xgboost when installing rapids from conda? like conda create -n rapids-22.08 -c rapidsai -c nvidia -c conda-forge \ rapids=22.08 python=3.9 cudatoolkit=11.5

trivialfis commented 2 years ago

@beckernick May have some insights into the packaging. My xgboost is almost always built from source ...

hcho3 commented 2 years ago

@wbo4958 Yes, installing rapids from Conda will also install rapids-xgboost from the rapidsai channel.

trivialfis commented 2 years ago

Closing this now since it's caused by the environment.