From d53a9c4e21e6f7575a3d676f80b08332b79623fa Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Tue, 9 Feb 2021 13:36:57 -0500 Subject: [PATCH] RDC Prometheus plugin return errors when use the --rdc_gpu_indexes When above option is used, the plugin returns errors: result = rdc.rdc_group_gpu_add(rdc_handle, gpu_group_id, gpu) ctypes.ArgumentError: argument 3: : wrong type The rdc_prometheus.py is changed to convert string to integer. The RdcUtil.py is also changed to raise Exception properly. Change-Id: I9535091ff1fc8882cccd32e5f2810da5241768c3 [ROCm/rdc commit: 7ca7a571a74d9870c6651231b4f158ee6a0de3f4] --- projects/rdc/python_binding/RdcUtil.py | 8 ++++---- projects/rdc/python_binding/rdc_prometheus.py | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/projects/rdc/python_binding/RdcUtil.py b/projects/rdc/python_binding/RdcUtil.py index ef4dce0096..4bea3d7c2c 100644 --- a/projects/rdc/python_binding/RdcUtil.py +++ b/projects/rdc/python_binding/RdcUtil.py @@ -54,13 +54,13 @@ class RdcUtil: gpu_group_id = c_uint32() result = rdc.rdc_group_gpu_create(rdc_handle, rdc_group_type_t.RDC_GROUP_EMPTY, gpu_group_name, gpu_group_id) if rdc_status_t(result) != rdc_status_t.RDC_ST_OK: - raise Exception("Fail to create the GPU group " << group_name) + raise Exception("Fail to create the GPU group " + group_name) #Add GPU index to the group for gpu in gpu_indexes: result = rdc.rdc_group_gpu_add(rdc_handle, gpu_group_id, gpu) if rdc_status_t(result) != rdc_status_t.RDC_ST_OK: - raise Exception("Fail to add GPU index " << gpu <<" to group " << gpu_group_id) + raise Exception("Fail to add GPU index " + str(gpu) + " to group " + str(gpu_group_id)) return gpu_group_id, True @@ -75,7 +75,7 @@ class RdcUtil: group_info = rdc_field_group_info_t() result = rdc.rdc_group_field_get_info(rdc_handle, field_group_id_list[index], pointer(group_info)) if rdc_status_t(result) != rdc_status_t.RDC_ST_OK: - raise Exception("Fail to get field group " << field_group_id_list[index] <<" info") + raise Exception("Fail to get field group " + str(field_group_id_list[index]) + " info") if group_info.group_name.decode("utf-8") == field_group_name: field_ids_ori = [ e.value for e in group_info.field_ids[:group_info.count] ] # reuse the old field group @@ -84,7 +84,7 @@ class RdcUtil: else: result = rdc.rdc_group_field_destroy(rdc_handle, field_group_id_list[index]) if rdc_status_t(result) != rdc_status_t.RDC_ST_OK: - raise Exception("Fail to delete field group " << field_group_id_list[index]) + raise Exception("Fail to delete field group " + str(field_group_id_list[index])) #Create new field group fields_c_ids = [] diff --git a/projects/rdc/python_binding/rdc_prometheus.py b/projects/rdc/python_binding/rdc_prometheus.py index 08894d51aa..ec9e733e30 100644 --- a/projects/rdc/python_binding/rdc_prometheus.py +++ b/projects/rdc/python_binding/rdc_prometheus.py @@ -88,6 +88,9 @@ if __name__ == '__main__': rdc_ip_port = args.rdc_ip_port if args.rdc_embedded: rdc_ip_port = None + if args.rdc_gpu_indexes != None: + for i in range(0, len(args.rdc_gpu_indexes)): + args.rdc_gpu_indexes[i] = int(args.rdc_gpu_indexes[i]) reader = PrometheusReader(rdc_ip_port, field_ids, args.rdc_update_freq*1000000, args.rdc_max_keep_age, args.rdc_max_keep_samples,