Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions oat/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Defining how components interface with each other."""
import os

import logging
from typing import Type

Expand Down Expand Up @@ -79,9 +81,11 @@ def get_program(
label=label,
)
)
local_resources[label] = local_multi_processing.PythonProcess(
env={"CUDA_VISIBLE_DEVICES": str(i)}
)

env = os.environ.copy()
if "CUDA_VISIBLE_DEVICES" not in env:
env["CUDA_VISIBLE_DEVICES"] = str(i)
local_resources[label] = local_multi_processing.PythonProcess(env=env)

# Learner.
master_addr = "0.0.0.0"
Expand All @@ -101,9 +105,13 @@ def get_program(
ipc_server,
)
program.add_node(master_learner, label=label)
local_resources[label] = local_multi_processing.PythonProcess(
env={"CUDA_VISIBLE_DEVICES": str(learner_gpus[0])}
)

# check if CUDA_VISIBLE_DEVICES it is already set
env = os.environ.copy()
if "CUDA_VISIBLE_DEVICES" not in env:
env["CUDA_VISIBLE_DEVICES"] = str(learner_gpus[0])
local_resources[label] = local_multi_processing.PythonProcess(env=env)

for i in range(1, len(learner_gpus)):
label = f"learner_{i}"
worker_learner = lp.PyClassNode(
Expand All @@ -119,8 +127,10 @@ def get_program(
ipc_server,
)
program.add_node(worker_learner, label=label)
local_resources[label] = local_multi_processing.PythonProcess(
env={"CUDA_VISIBLE_DEVICES": str(learner_gpus[i])}
)

return program, local_resources
env = os.environ.copy()
if "CUDA_VISIBLE_DEVICES" not in env:
env["CUDA_VISIBLE_DEVICES"] = str(learner_gpus[i])
local_resources[label] = local_multi_processing.PythonProcess(env=env)

return program, local_resources