diff --git a/tools/infer/utility.py b/tools/infer/utility.py index 7a4e8392c4dad4c63bc161c7c34e8976db0f66ff..e1c4cd891a75e538cd16183154f075ec8349d91d 100755 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -20,6 +20,7 @@ import numpy as np import json from PIL import Image, ImageDraw, ImageFont import math +import paddle from paddle import inference import time from ppocr.utils.logging import get_logger @@ -286,11 +287,17 @@ def create_predictor(args, mode, logger): def get_infer_gpuid(): - cmd = "nvidia-smi" + if not paddle.fluid.core.is_compiled_with_rocm(): + cmd = "nvidia-smi" + else: + cmd = "rocm-smi" res = os.popen(cmd).readlines() if len(res) == 0: return None - cmd = "env | grep CUDA_VISIBLE_DEVICES" + if not paddle.fluid.core.is_compiled_with_rocm(): + cmd = "env | grep CUDA_VISIBLE_DEVICES" + else: + cmd = "env | grep HIP_VISIBLE_DEVICES" env_cuda = os.popen(cmd).readlines() if len(env_cuda) == 0: return 0