Skip to content

Commit

Permalink
Fix parser logic
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjurado committed Dec 19, 2023
1 parent b6bc2df commit c79b896
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 8 additions & 4 deletions mlcube/mlcube/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,17 @@ def parse_extra_arg(
key = "--security-opt" if platform == "docker" else "--security"
runner_run_args[key] = parsed_args["security"]
if parsed_args.get("gpus", None):
cuda_visible_devices = parsed_args["gpus"]
if "device" in cuda_visible_devices:
cuda_visible_devices = cuda_visible_devices.replace("device=", "")
elif str(cuda_visible_devices).isnumeric():
cuda_visible_devices = str(list(range(int(cuda_visible_devices))))
cuda_visible_devices = cuda_visible_devices.replace(" ", "")[1:-1]
if platform == "docker":
runner_run_args["--gpus"] = parsed_args["gpus"]
runner_run_args["--gpus"] = cuda_visible_devices
else:
runner_run_args["--nv"] = ""
os.environ["SINGULARITYENV_CUDA_VISIBLE_DEVICES"] = parsed_args[
"gpus"
]
os.environ["SINGULARITYENV_CUDA_VISIBLE_DEVICES"] = cuda_visible_devices
if parsed_args.get("memory", None):
key = "--memory" if platform == "docker" else "--vm-ram"
runner_run_args[key] = parsed_args["memory"]
Expand Down
3 changes: 0 additions & 3 deletions runners/mlcube_docker/mlcube_docker/docker_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,8 @@ def run(self) -> None:

valid_gpu_flag = "--gpus" in self.mlcube.runner and self.mlcube.runner["--gpus"] is not None


if valid_gpu_flag:
cuda_visible_devices = self.mlcube.runner["--gpus"]
if "device" in cuda_visible_devices:
cuda_visible_devices = cuda_visible_devices.replace("device=", "")
else:
cuda_visible_devices = num_gpus

Expand Down

0 comments on commit c79b896

Please sign in to comment.