Skip to content

Commit 4989e6e

Browse files
committed
remove rocm dependency in packager
Signed-off-by: Vicky Tsang <vtsang@amd.com>
1 parent 0e475f4 commit 4989e6e

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

monai/deploy/packager/util.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from monai.deploy.exceptions import WrongValueError
2424
from monai.deploy.packager.constants import DefaultValues
2525
from monai.deploy.packager.templates import Template
26-
from monai.deploy.utils.deviceutil import has_rocm
2726
from monai.deploy.utils.fileutil import checksum
2827
from monai.deploy.utils.importutil import dist_module_path, dist_requires, get_application
2928
from monai.deploy.utils.spinner import ProgressSpinner
@@ -43,8 +42,8 @@ def verify_base_image(base_image: str) -> str:
4342
str: returns string identifier of the dockerfile template to build MAP
4443
if valid base image provided, returns empty string otherwise
4544
"""
46-
if has_rocm():
47-
valid_prefixes = {"rocm": "ubuntu", "rocm/pytorch": "pytorch"}
45+
if "rocm" in base_image:
46+
valid_prefixes = {"rocm/pytorch": "ubuntu"}
4847
else:
4948
valid_prefixes = {"nvcr.io/nvidia/cuda": "ubuntu", "nvcr.io/nvidia/pytorch": "pytorch"}
5049

@@ -93,20 +92,13 @@ def initialize_args(args: Namespace) -> Dict:
9392
if args.base:
9493
dockerfile_type = verify_base_image(args.base)
9594
if not dockerfile_type:
96-
if has_rocm():
97-
logger.error(
98-
"Provided base image '{}' is not supported \n \
99-
Please provide a ROCm or Pytorch image from https://hub.docker.com/r/rocm/pytorch".format(
100-
args.base
101-
)
102-
)
103-
else:
104-
logger.error(
105-
"Provided base image '{}' is not supported \n \
106-
Please provide a Cuda or Pytorch image from https://ngc.nvidia.com/ (nvcr.io/nvidia)".format(
107-
args.base
108-
)
95+
logger.error(
96+
"Provided base image '{}' is not supported \n \
97+
Please provide a ROCm or Cuda based Pytorch image from \n \
98+
https://hub.docker.com/r/rocm/pytorch or https://ngc.nvidia.com/ (nvcr.io/nvidia)".format(
99+
args.base
109100
)
101+
)
110102

111103
sys.exit(1)
112104

monai/deploy/utils/deviceutil.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ def has_rocm():
2121
True if ROCm is installed and GPU device is detected, otherwise False.
2222
"""
2323
cmd = "rocminfo"
24-
process = subprocess.run([cmd], stdout=subprocess.PIPE)
25-
for line_in in process.stdout.decode().splitlines():
26-
if "Device Type" in line_in and "GPU" in line_in:
27-
return True
24+
try:
25+
process = subprocess.run([cmd], stdout=subprocess.PIPE)
26+
for line_in in process.stdout.decode().splitlines():
27+
if "Device Type" in line_in and "GPU" in line_in:
28+
return True
29+
except Exception:
30+
pass
2831

2932
return False
3033

0 commit comments

Comments
 (0)