Skip to content

Conversation

@wbo4958
Copy link
Contributor

@wbo4958 wbo4958 commented Jan 19, 2026

Ref to: #11884

This PR adds JNI functions to manage CUDA device selection for XGBoost Spark, and and allows Spark executors to explicitly set and acquire GPU devices before XGBoost training, relying on Spark's resource scheduler to prevent GPU conflicts between executors.

@wbo4958
Copy link
Contributor Author

wbo4958 commented Jan 20, 2026

Hi @trivialfis, Please help review it.

* Method: CudaSetDevice
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_CudaSetDevice(JNIEnv *, jclass,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consolidate this function into xgboost4j.cpp, then use the SetDevice function from cuda_rt_utils.h file, which can handle CUDA build and CPU-only build

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@wbo4958 wbo4958 requested a review from trivialfis January 21, 2026 08:26
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

Successfully merging this pull request may close these issues.

2 participants