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

[PySpark] add gpu support for spark local mode #8068

Merged
merged 5 commits into from Jul 16, 2022

Conversation

wbo4958
Copy link
Contributor

@wbo4958 wbo4958 commented Jul 13, 2022

This PR is to support gpu training (use_gpu=True) on Spark local mode.

Please note that,

  1. Spark local mode does not support GPU configuration, so it will fail if the user adds related GPU configurations.
  2. For now, we only support num_workers=1 when running on GPU on Spark local mode.

This feature is needed since it's really convenient for local debugging.

@wbo4958
Copy link
Contributor Author

wbo4958 commented Jul 13, 2022

@trivialfis How to run python tests locally? is there a doc for that?

@trivialfis
Copy link
Member

pytest ./tests/python

You can check the doc for pytest.

Comment on lines 300 to 304
if self.getOrDefault(self.num_workers) > 1:
raise ValueError(
"Training XGBoost on the spark local mode only supports num_workers = 1, "
+ "and only primary GPU device will be used."
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can still support multiple GPU workers in spark local mode.
We can get partition id from spark TaskContext, and use the partition id as the gpu_id for the corresponding spark task. WDYT ?

Copy link
Contributor Author

@wbo4958 wbo4958 Jul 14, 2022

Choose a reason for hiding this comment

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

Thx. Hmm, there will be only 1 process for spark local mode, If we support the scenario of num_workers > 1, then all the GPU training tasks will run on the same process, which seems not to be supported due to the NCCL issue. eg,

Task1 taking GPU 0 runs on Process1
Task2 taking GPU 1 runs on Process1

@trivialfis is this supported by xgboost?

Copy link
Member

Choose a reason for hiding this comment

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

It should work but let's not invite trouble.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I agree. The GPU supporting for the local mode is mostly used in local debugging.

Copy link
Contributor

Choose a reason for hiding this comment

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

@wbo4958
A correction:

local mode pyspark all the GPU training tasks will run on the same process

This is not true.
For pyspark, in barrier mode pyspark task, each python UDF task will be run in an individual python process (in pyspark code, the process is called python worker).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh right, my bad. I previously thought it was the JVM side. Ok, let me add it support.

@trivialfis
Copy link
Member

Please address the linter error.

Copy link
Contributor

@WeichenXu123 WeichenXu123 left a comment

Choose a reason for hiding this comment

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

LGTM

@trivialfis trivialfis merged commit a33f35e into dmlc:master Jul 16, 2022
@wbo4958 wbo4958 deleted the pyspark-local-gpu branch April 23, 2024 09:27
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.

None yet

3 participants