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

eval_safe not returning on R 4.2 for xgboost model predictions #6

Open
Helbrax opened this issue Oct 27, 2022 · 3 comments
Open

eval_safe not returning on R 4.2 for xgboost model predictions #6

Helbrax opened this issue Oct 27, 2022 · 3 comments

Comments

@Helbrax
Copy link

Helbrax commented Oct 27, 2022

I've recently upgraded a linux container to use R 4.2.1 and upgraded unix r package to 1.5.5 from 1.5.4.

I noticed after doing so, that certain requests were timing out/never completing. Upon further investigation, it looks like the code is no longer returning when being run under eval_safe. So far, I think I've narrowed it down to the "predict" method when called on an xgboost model.

Old session Info
`R version 4.1.1 (2021-08-10) -- xgboost here is 1.5.0.2
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
[1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
[4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C
[7] LC_PAPER=C LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=C LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base `

New session info
`R version 4.2.1 (2022-06-23) -- xgboost here is 1.6.0.1
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.5 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
[1] C

attached base packages:
[1] stats graphics grDevices utils datasets methods base`

R results
`> predict(m, x, outputmargin=TRUE)
[1] -1.160798

unix::eval_safe(predict(m, x, outputmargin=TRUE))
^C
^C
Error in tryCatch({ : process interrupted by parent
unix::eval_safe(paste0("foo", "bar"))
[1] "foobar"
`

@Helbrax
Copy link
Author

Helbrax commented Oct 31, 2022

Quick update on this. If OMP_NUM_THREADS is set to 1, eval_safe runs fine. It's only when OMP_NUM_THREADS is not set and the predict model is running on all available cpu.
I've tried this at 8 vcpu with OMP_NUM_THREADS set to 1 and had no issue but leaving it unset caused eval_safe to hang. Setting the vcpu down to 1 and leaving OMP_NUM_THREADS unset also had no issue. This seems to be only when multi-cores are used.
Not sure if the issue is with eval_safe or some new threading issue with predict xgboost modeling using multiple cores.

@jeroen
Copy link
Owner

jeroen commented Oct 31, 2022

Can you include a complete reproducible example? Including an example model and x

@Helbrax
Copy link
Author

Helbrax commented Nov 1, 2022

See below.

library(xgboost)
library(unix)

data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
train <- agaricus.train
test <- agaricus.test
dtrain <- xgb.DMatrix(data = train$data, label = train$label)
bst <- xgboost(data = dtrain, max.depth = 2, eta = 1, nthread = 2, nrounds = 2, objective = "binary:logistic", verbose = 0)
x <- predict(bst, test$data) # this complets
eval_safe(predict(bst, test$data)) # this hangs. if you change nthread=2 to nthead=1 in the training, it completes, OR load the model in and set OMP_NUM_THREADS=1 in environment variables

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

No branches or pull requests

2 participants