Stackdriver Profiler Python agent is a tool that continuously gathers CPU usage information from Python applications
Apache License 2.0
27
stars
23
forks
source link
Python 3.12 `xgboost.core.XGBoostError: Invalid Parameter format for nthread expect int but value='-1'` when `DMatrix` used with `import googlecloudprofiler`. #144
Traceback (most recent call last):
File "/project/path/file.py", line 4, in <module>
DMatrix([[]])
File "/venv/path/lib/python3.12/site-packages/xgboost/core.py", line 730, in inner_f
return func(**kwargs)
^^^^^^^^^^^^^^
File "/venv/path/lib/python3.12/site-packages/xgboost/core.py", line 857, in __init__
handle, feature_names, feature_types = dispatch_data_backend(
^^^^^^^^^^^^^^^^^^^^^^
File "/venv/path/lib/python3.12/site-packages/xgboost/data.py", line 1081, in dispatch_data_backend
return _from_list(data, missing, threads, feature_names, feature_types)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/venv/path/lib/python3.12/site-packages/xgboost/data.py", line 1011, in _from_list
return _from_numpy_array(array, missing, n_threads, feature_names, feature_types)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/venv/path/lib/python3.12/site-packages/xgboost/data.py", line 207, in _from_numpy_array
_check_call(
File "/venv/path/lib/python3.12/site-packages/xgboost/core.py", line 282, in _check_call
raise XGBoostError(py_str(_LIB.XGBGetLastError()))
xgboost.core.XGBoostError: Invalid Parameter format for nthread expect int but value='-1'
To "solve" the problem remove import googlecloudprofiler from file.py. I really have no idea why just importing the lib causes this problem; it would make more sense after googlecloudprofiler.start is called.
Moreover the code works for xgboost=1.7.6 and fails since xgboost=2.0.0.
Maintainer of xgboost mentioned
loading the _profiler.cpython-312-x86_64-linux-gnu.so inside google profiler extension causes the error
This issue was originally posted in
xgboost
repo https://github.com/dmlc/xgboost/issues/10224 .Hi
I have a very peculiar error which happened when I've updated versions of Python and libs in project I'm working on.
Minimal example to reproduce the case is this:
Python 3.12.2
Install with
Run with
Results in
To "solve" the problem remove
import googlecloudprofiler
fromfile.py
. I really have no idea why just importing the lib causes this problem; it would make more sense aftergooglecloudprofiler.start
is called.Moreover the code works for
xgboost=1.7.6
and fails sincexgboost=2.0.0
.Maintainer of
xgboost
mentionedhttps://github.com/dmlc/xgboost/issues/10224#issuecomment-2077751030
This is why I've opened issue here.