mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 03:34:48 +08:00
Automatically set CUDA_VISIBLE_DEVICES when worker gets task. (#1044)
* Automatically set CUDA_VISIBLE_DEVICES when worker gets task. * Add test.
This commit is contained in:
committed by
Philipp Moritz
parent
4669c59fa8
commit
a52a1e893f
@@ -868,6 +868,11 @@ class Worker(object):
|
||||
"""
|
||||
with log_span("ray:get_task", worker=self):
|
||||
task = self.local_scheduler_client.get_task()
|
||||
|
||||
# Automatically restrict the GPUs available to this task.
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = ",".join(
|
||||
[str(i) for i in ray.get_gpu_ids()])
|
||||
|
||||
return task
|
||||
|
||||
def main_loop(self):
|
||||
|
||||
Reference in New Issue
Block a user