Skip to content

Commit ced2562

Browse files
committed
set pt dir to LD_LIBRARY_PATH
Signed-off-by: Jinzhe Zeng <[email protected]>
1 parent 2e91ce8 commit ced2562

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

deepmd/tf/lmp.py

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
from importlib import (
77
import_module,
88
)
9+
from importlib.util import (
10+
find_spec,
11+
)
912
from pathlib import (
1013
Path,
1114
)
@@ -77,6 +80,11 @@ def get_library_path(module: str, filename: str) -> List[str]:
7780

7881
tf_dir = tf.sysconfig.get_lib()
7982
op_dir = str(SHARED_LIB_DIR)
83+
pt_spec = find_spec("torch")
84+
if pt_spec is not None:
85+
pt_dir = pt_spec.submodule_search_locations[0]
86+
else:
87+
pt_dir = None
8088

8189

8290
cuda_library_paths = []
@@ -106,6 +114,7 @@ def get_library_path(module: str, filename: str) -> List[str]:
106114
[
107115
os.environ.get(lib_env),
108116
tf_dir,
117+
pt_dir,
109118
os.path.join(tf_dir, "python"),
110119
op_dir,
111120
]

0 commit comments

Comments
 (0)