From 4839075a8621831e9f8f6a918abcd54e9bfa4ebb Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Mon, 30 Nov 2020 13:42:59 -0500 Subject: [PATCH] Use relative path to find librdc_bootstrap.so The python script will search list of the installation folders to find the librdc_bootstrap.so. Change-Id: I52e444e6d153c318c731c4b2cd0d8e39b0fd31ca [ROCm/rdc commit: 4b3dbc469710c8ec41e076085079b6357cab71f9] --- projects/rdc/python_binding/rdc_bootstrap.py | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/projects/rdc/python_binding/rdc_bootstrap.py b/projects/rdc/python_binding/rdc_bootstrap.py index c0c9caed21..f21f2b5e6d 100644 --- a/projects/rdc/python_binding/rdc_bootstrap.py +++ b/projects/rdc/python_binding/rdc_bootstrap.py @@ -4,9 +4,29 @@ from ctypes import * from enum import Enum librdc = "librdc_bootstrap.so" + # The python ctypes wrapper for "librdc_bootstrap.so" -rdc = CDLL(librdc) +# Search librdc_bootstrap.so paths +current_folder = os.path.dirname(os.path.realpath(__file__)) +rdc_paths = [ "", # without path + current_folder+"/../lib/", # package installation + current_folder+"/../lib64/", # package installation + current_folder+"/../build/rdc_libs/" # build from source code +] + +rdc = None +for r in rdc_paths: + try: + rdc = CDLL(r+librdc) + break + except: + pass + +if rdc == None: + print("Unable to load the librdc_bootstrap.so. Set LD_LIBRARY_PATH to the folder containing librdc_bootstrap.so.") + exit(1) + GPU_ID_INVALID = -1 RDC_GROUP_ALL_GPUS = -1000