Skip to content

Commit 8de6596

Browse files
authored
ci(package-c): build pytorch plugin without bundled runtime (deepmodeling#5706)
## Summary - build the C package in the manylinux_2_28 CUDA 12.9 image and install TensorFlow/PyTorch from dependency groups - package the PyTorch backend plugin while excluding libtorch/CUDA runtime libraries from the tarball - add package README/download_libtorch.sh guidance and update C package tests for external PyTorch runtime - avoid CUDA 12.9 CCCL failures from -arch=all by using all-major as the CUDA 12.9 default ## Tests - ruff check . - ruff format . - git diff --check - sh -n source/install/package_c.sh - bash -n source/install/docker_package_c.sh - bash -n source/install/docker_test_package_c.sh - fork CI on bbcd58d: Build C library, Build C++, Build/upload to PyPI, CodeQL, Test C++, and Test Python all passed Fork CI: https://github.com/njzjz/deepmd-kit/actions/runs/28547373402 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Expanded C library packaging and installation to support PyTorch in addition to TensorFlow and JAX. * When PyTorch is enabled, the package can generate a matching libtorch download helper and runtime setup guidance. * **Bug Fixes** * Added stronger packaging verification to ensure required shared libraries are present and to prevent accidental bundling of PyTorch/CUDA runtime libraries. * **Documentation** * Updated C library installation docs with PyTorch version/compatibility guidance and runtime environment setup (including `LD_LIBRARY_PATH`). <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent ffe57a3 commit 8de6596

7 files changed

Lines changed: 427 additions & 56 deletions

File tree

.github/workflows/package_c.yml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ jobs:
2121
strategy:
2222
matrix:
2323
include:
24-
- tensorflow_build_version: "2.20"
25-
tensorflow_version: "==2.20.*"
24+
- package_c_runtime_dependency_pre_exclude_regexes: 'libtorch.*\.so.*;libc10.*\.so.*;libshm\.so.*;libkineto\.so.*;libbackend_with_compiler\.so.*;libcaffe2.*\.so.*;libcuda.*\.so.*;libcudart.*\.so.*;libcublas.*\.so.*;libcufft.*\.so.*;libcufile.*\.so.*;libcupti.*\.so.*;libcurand.*\.so.*;libcusolver.*\.so.*;libcusparse.*\.so.*;libnv.*\.so.*;libcudnn.*\.so.*;libnccl.*\.so.*'
25+
package_c_runtime_dependency_post_exclude_regexes: '.*/libtorch.*\.so.*;.*/libc10.*\.so.*;.*/libshm\.so.*;.*/libkineto\.so.*;.*/libbackend_with_compiler\.so.*;.*/libcaffe2.*\.so.*;.*/libcuda.*\.so.*;.*/libcudart.*\.so.*;.*/libcublas.*\.so.*;.*/libcufft.*\.so.*;.*/libcufile.*\.so.*;.*/libcupti.*\.so.*;.*/libcurand.*\.so.*;.*/libcusolver.*\.so.*;.*/libcusparse.*\.so.*;.*/libnv.*\.so.*;.*/libcudnn.*\.so.*;.*/libnccl.*\.so.*'
2626
filename: libdeepmd_c.tar.gz
2727
steps:
2828
- name: Free Disk Space (Ubuntu)
@@ -41,8 +41,30 @@ jobs:
4141
- name: Package C library
4242
run: ./source/install/docker_package_c.sh
4343
env:
44-
TENSORFLOW_VERSION: ${{ matrix.tensorflow_version }}
45-
TENSORFLOW_BUILD_VERSION: ${{ matrix.tensorflow_build_version }}
44+
ENABLE_PYTORCH: "TRUE"
45+
PACKAGE_C_RUNTIME_DEPENDENCY_PRE_EXCLUDE_REGEXES: ${{ matrix.package_c_runtime_dependency_pre_exclude_regexes }}
46+
PACKAGE_C_RUNTIME_DEPENDENCY_POST_EXCLUDE_REGEXES: ${{ matrix.package_c_runtime_dependency_post_exclude_regexes }}
47+
- name: Check C library package contents
48+
run: |
49+
tar -tzf libdeepmd_c.tar.gz | tee libdeepmd_c.contents
50+
grep -q 'libdeepmd_c/lib/libdeepmd_backend_tf.so' libdeepmd_c.contents
51+
grep -q 'libdeepmd_c/lib/libdeepmd_backend_pt.so' libdeepmd_c.contents
52+
grep -q 'libdeepmd_c/lib/libdeepmd_backend_ptexpt.so' libdeepmd_c.contents
53+
grep -q 'libdeepmd_c/lib/libdeepmd_op_pt.so' libdeepmd_c.contents
54+
grep -q 'libdeepmd_c/download_libtorch.sh' libdeepmd_c.contents
55+
if grep -E 'libdeepmd_c/lib/(libtorch|libc10|libshm|libkineto|libbackend_with_compiler|libcaffe2|libcuda|libcudart|libcublas|libcufft|libcufile|libcupti|libcurand|libcusolver|libcusparse|libnv|libcudnn|libnccl)' libdeepmd_c.contents; then
56+
echo "PyTorch/CUDA runtime libraries must not be bundled in libdeepmd_c.tar.gz"
57+
exit 1
58+
fi
59+
- name: Note external PyTorch runtime
60+
run: |
61+
libtorch_url=$(tar -xOf libdeepmd_c.tar.gz libdeepmd_c/download_libtorch.sh | sed -n 's/^LIBTORCH_DOWNLOAD_URL="\(.*\)"$/\1/p')
62+
{
63+
echo "PyTorch support was built into the C package, but PyTorch runtime libraries are not bundled."
64+
echo "Download matching libtorch from: ${libtorch_url}"
65+
echo "Or run ./download_libtorch.sh after extracting libdeepmd_c.tar.gz."
66+
echo "The PyTorch version must match the build version exactly; the CUDA variant may be omitted only when compatible."
67+
} >> "$GITHUB_STEP_SUMMARY"
4668
- run: cp libdeepmd_c.tar.gz ${{ matrix.filename }}
4769
if: matrix.filename != 'libdeepmd_c.tar.gz'
4870
# for download and debug
@@ -53,6 +75,8 @@ jobs:
5375
path: ${{ matrix.filename }}
5476
- name: Test C library
5577
run: ./source/install/docker_test_package_c.sh
78+
env:
79+
CHECK_PYTORCH_RUNTIME: "1"
5680
- name: Release
5781
uses: softprops/action-gh-release@v3
5882
if: startsWith(github.ref, 'refs/tags/')

doc/install/install-from-c-library.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Install from pre-compiled C library {{ tensorflow_icon }} {{ jax_icon }}
1+
# Install from pre-compiled C library {{ tensorflow_icon }} {{ pytorch_icon }} {{ jax_icon }}
22

33
:::{note}
4-
**Supported backends**: TensorFlow {{ tensorflow_icon }}, JAX {{ jax_icon }}
4+
**Supported backends**: TensorFlow {{ tensorflow_icon }}, PyTorch {{ pytorch_icon }}, JAX {{ jax_icon }}
55
:::
66

77
DeePMD-kit provides pre-compiled C library package (`libdeepmd_c.tar.gz`) in each [release](https://github.com/deepmodeling/deepmd-kit/releases). It can be used to build the [LAMMPS plugin](./install-lammps.md) and the [i-PI driver](./install-ipi.md), as well as many [third-party software packages](../third-party/out-of-deepmd-kit.md), without building TensorFlow and DeePMD-kit on one's own.
@@ -12,7 +12,17 @@ wget https://github.com/deepmodeling/deepmd-kit/releases/latest/download/libdeep
1212
tar xzf libdeepmd_c.tar.gz
1313
```
1414

15-
The library is built in Linux (GLIBC 2.17) with CUDA 12.2 (`libdeepmd_c.tar.gz`). It's noted that this package does not contain CUDA Toolkit and cuDNN, so one needs to download them from the NVIDIA website.
15+
The library is built in Linux (GLIBC 2.28) with CUDA 12.9 (`libdeepmd_c.tar.gz`). It's noted that this package does not contain CUDA Toolkit, cuDNN, or PyTorch runtime libraries.
16+
To use the PyTorch C/C++ backend on Linux, install a libtorch runtime that exactly matches the PyTorch version used to build the package.
17+
The PyTorch version must match exactly, while the CUDA variant may be omitted only when the target runtime is compatible.
18+
Make the libtorch `lib` directory discoverable by the dynamic linker, for example by adding it to `LD_LIBRARY_PATH`.
19+
The C library package includes `download_libtorch.sh`, which downloads and unpacks the matching libtorch runtime and writes `libtorch_env.sh`:
20+
21+
```sh
22+
cd libdeepmd_c
23+
./download_libtorch.sh
24+
. ./libtorch_env.sh
25+
```
1626

1727
## Use Pre-compiled C Library to build the LAMMPS plugin and i-PI driver
1828

source/api_c/CMakeLists.txt

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,78 @@ endif(BUILD_PY_IF)
3131

3232
if(PACKAGE_C)
3333
message(STATUS "Packaging C API library")
34+
set(PACKAGE_C_RUNTIME_DEPENDENCY_PRE_EXCLUDE_REGEXES
35+
""
36+
CACHE STRING
37+
"Additional file(GET_RUNTIME_DEPENDENCIES) pre-exclude regexes")
38+
set(PACKAGE_C_RUNTIME_DEPENDENCY_POST_EXCLUDE_REGEXES
39+
""
40+
CACHE STRING
41+
"Additional file(GET_RUNTIME_DEPENDENCIES) post-exclude regexes")
42+
set(PACKAGE_C_RUNTIME_DEPENDENCY_PRE_EXCLUDE_REGEXES_DEFAULT
43+
"libgcc_s\\.so.*"
44+
"libstdc\\+\\+\\.so.*"
45+
"libm\\.so.*"
46+
"libdl\\.so.*"
47+
"librt\\.so.*"
48+
"libc\\.so.*"
49+
"libpthread\\.so.*"
50+
"ld-.*\\.so.*"
51+
"libgomp\\.so.*")
52+
set(PACKAGE_C_RUNTIME_DEPENDENCY_PRE_EXCLUDE_REGEXES_ALL
53+
${PACKAGE_C_RUNTIME_DEPENDENCY_PRE_EXCLUDE_REGEXES_DEFAULT}
54+
${PACKAGE_C_RUNTIME_DEPENDENCY_PRE_EXCLUDE_REGEXES})
3455
get_property(DEEPMD_BACKEND_PLUGIN_TARGETS GLOBAL
3556
PROPERTY DEEPMD_BACKEND_PLUGIN_TARGETS)
36-
set(PACKAGE_C_RUNTIME_LIBRARIES "$<TARGET_FILE:${libname}>"
37-
"$<TARGET_FILE:${LIB_DEEPMD_OP}>")
57+
set(PACKAGE_C_RUNTIME_LIBRARIES "$<TARGET_FILE:${libname}>")
58+
if(TARGET ${LIB_DEEPMD_OP})
59+
list(APPEND PACKAGE_C_RUNTIME_LIBRARIES "$<TARGET_FILE:${LIB_DEEPMD_OP}>")
60+
endif()
61+
foreach(_target deepmd_op_pt deepmd_op_pd)
62+
if(TARGET ${_target})
63+
list(APPEND PACKAGE_C_RUNTIME_LIBRARIES "$<TARGET_FILE:${_target}>")
64+
endif()
65+
endforeach()
3866
foreach(_target ${DEEPMD_BACKEND_PLUGIN_TARGETS})
3967
list(APPEND PACKAGE_C_RUNTIME_LIBRARIES "$<TARGET_FILE:${_target}>")
4068
endforeach()
4169
string(REPLACE ";" " " PACKAGE_C_RUNTIME_LIBRARIES_CODE
4270
"${PACKAGE_C_RUNTIME_LIBRARIES}")
4371
# follow pypa/auditwheel convention
4472
install(CODE "set(_dp_runtime_libraries ${PACKAGE_C_RUNTIME_LIBRARIES_CODE})")
73+
install(
74+
CODE "set(_dp_package_c_lib_dir [==[${CMAKE_BINARY_DIR}/libdeepmd_c/lib]==])
75+
set(_dp_runtime_pre_exclude_regexes [==[${PACKAGE_C_RUNTIME_DEPENDENCY_PRE_EXCLUDE_REGEXES_ALL}]==])
76+
set(_dp_runtime_post_exclude_regexes [==[${PACKAGE_C_RUNTIME_DEPENDENCY_POST_EXCLUDE_REGEXES}]==])"
77+
)
4578
install(
4679
CODE [[
4780
file(GET_RUNTIME_DEPENDENCIES
4881
LIBRARIES ${_dp_runtime_libraries}
4982
RESOLVED_DEPENDENCIES_VAR _r_deps
50-
PRE_EXCLUDE_REGEXES "libgcc_s\\.so.*"
51-
"libstdc\\+\\+\\.so.*"
52-
"libm\\.so.*"
53-
"libdl\\.so.*"
54-
"librt\\.so.*"
55-
"libc\\.so.*"
56-
"libpthread\\.so.*"
57-
"ld-.*\\.so.*"
58-
"libgomp\\.so.*"
83+
PRE_EXCLUDE_REGEXES ${_dp_runtime_pre_exclude_regexes}
84+
POST_EXCLUDE_REGEXES ${_dp_runtime_post_exclude_regexes}
5985
)
6086
message(STATUS "Runtime dependencies: ${_r_deps}")
6187
foreach(_file ${_r_deps})
62-
file(INSTALL ${_file} DESTINATION libdeepmd_c/lib
88+
file(INSTALL ${_file} DESTINATION "${_dp_package_c_lib_dir}"
6389
FOLLOW_SYMLINK_CHAIN
6490
)
6591
endforeach()
6692
]])
6793
install(FILES ${INC_SRC}
6894
DESTINATION ${CMAKE_BINARY_DIR}/libdeepmd_c/include/deepmd)
6995
install(TARGETS ${libname} DESTINATION ${CMAKE_BINARY_DIR}/libdeepmd_c/lib)
70-
install(TARGETS ${LIB_DEEPMD_OP}
71-
DESTINATION ${CMAKE_BINARY_DIR}/libdeepmd_c/lib)
96+
if(TARGET ${LIB_DEEPMD_OP})
97+
install(TARGETS ${LIB_DEEPMD_OP}
98+
DESTINATION ${CMAKE_BINARY_DIR}/libdeepmd_c/lib)
99+
endif()
100+
foreach(_target deepmd_op_pt deepmd_op_pd)
101+
if(TARGET ${_target})
102+
install(TARGETS ${_target}
103+
DESTINATION ${CMAKE_BINARY_DIR}/libdeepmd_c/lib)
104+
endif()
105+
endforeach()
72106
foreach(_target ${DEEPMD_BACKEND_PLUGIN_TARGETS})
73107
install(TARGETS ${_target} DESTINATION ${CMAKE_BINARY_DIR}/libdeepmd_c/lib)
74108
endforeach()

source/install/docker_package_c.sh

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,39 @@
11
set -e
22

3-
SCRIPT_PATH=$(dirname $(realpath -s $0))
3+
SCRIPT_PATH=$(dirname "$(realpath -s "$0")")
4+
MANYLINUX_CUDA_IMAGE=${MANYLINUX_CUDA_IMAGE:-quay.io/manylinux_cuda/manylinux_2_28_x86_64_cuda12_9:latest}
5+
PYTHON_BIN=${PYTHON_BIN:-/opt/python/cp311-cp311/bin/python}
6+
PYTORCH_DEPENDENCY_GROUP=${PYTORCH_DEPENDENCY_GROUP:-pin_pytorch_cpu}
7+
PYTORCH_TORCH_BACKEND=${PYTORCH_TORCH_BACKEND:-cpu}
8+
TENSORFLOW_DEPENDENCY_GROUP=${TENSORFLOW_DEPENDENCY_GROUP:-pin_tensorflow_cpu}
49

5-
docker run --rm -v ${SCRIPT_PATH}/../..:/root/deepmd-kit -w /root/deepmd-kit \
6-
tensorflow/build:${TENSORFLOW_BUILD_VERSION:-2.15}-python3.11 \
7-
/bin/sh -c "pip install \"tensorflow${TENSORFLOW_VERSION}\" cmake \
8-
&& git config --global --add safe.directory /root/deepmd-kit \
9-
&& cd /root/deepmd-kit/source/install \
10-
&& CC=/dt9/usr/bin/gcc \
11-
CXX=/dt9/usr/bin/g++ \
12-
/bin/sh package_c.sh"
10+
docker run --rm -v "${SCRIPT_PATH}/../..":/root/deepmd-kit -w /root/deepmd-kit \
11+
-e CIBUILDWHEEL="${CIBUILDWHEEL:-1}" \
12+
-e ENABLE_PYTORCH="${ENABLE_PYTORCH:-FALSE}" \
13+
-e MANYLINUX_CUDA_IMAGE="${MANYLINUX_CUDA_IMAGE}" \
14+
-e PACKAGE_C_RUNTIME_DEPENDENCY_PRE_EXCLUDE_REGEXES="${PACKAGE_C_RUNTIME_DEPENDENCY_PRE_EXCLUDE_REGEXES:-}" \
15+
-e PACKAGE_C_RUNTIME_DEPENDENCY_POST_EXCLUDE_REGEXES="${PACKAGE_C_RUNTIME_DEPENDENCY_POST_EXCLUDE_REGEXES:-}" \
16+
-e PYTORCH_DEPENDENCY_GROUP="${PYTORCH_DEPENDENCY_GROUP}" \
17+
-e PYTHON_BIN="${PYTHON_BIN}" \
18+
-e PYTORCH_RUNTIME_DOWNLOAD_URL="${PYTORCH_RUNTIME_DOWNLOAD_URL:-}" \
19+
-e PYTORCH_TORCH_BACKEND="${PYTORCH_TORCH_BACKEND}" \
20+
-e TENSORFLOW_DEPENDENCY_GROUP="${TENSORFLOW_DEPENDENCY_GROUP}" \
21+
"${MANYLINUX_CUDA_IMAGE}" \
22+
/bin/bash -lc 'set -euo pipefail
23+
export PATH="$(dirname "${PYTHON_BIN}"):${PATH}"
24+
"${PYTHON_BIN}" -m pip install uv
25+
UV_INSTALL_ARGS=(
26+
pip install
27+
--python "${PYTHON_BIN}"
28+
cmake
29+
ninja
30+
patchelf
31+
--group "${TENSORFLOW_DEPENDENCY_GROUP}"
32+
)
33+
if [ "${ENABLE_PYTORCH}" = "TRUE" ]; then
34+
UV_INSTALL_ARGS+=(--group "${PYTORCH_DEPENDENCY_GROUP}" --torch-backend "${PYTORCH_TORCH_BACKEND}")
35+
fi
36+
source/install/uv_with_retry.sh "${UV_INSTALL_ARGS[@]}"
37+
git config --global --add safe.directory /root/deepmd-kit
38+
cd /root/deepmd-kit/source/install
39+
/bin/sh package_c.sh'
Lines changed: 89 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,94 @@
1-
# test libdeepmd_c.tar.gz works with gcc 4.9.0, glibc 2.19
1+
# test libdeepmd_c.tar.gz works on a manylinux 2.28 runtime
22
set -e
33

4-
SCRIPT_PATH=$(dirname $(realpath -s $0))
4+
SCRIPT_PATH=$(dirname "$(realpath -s "$0")")
5+
MANYLINUX_IMAGE=${MANYLINUX_IMAGE:-quay.io/pypa/manylinux_2_28_x86_64:latest}
6+
PYTHON_BIN=${PYTHON_BIN:-/opt/python/cp311-cp311/bin/python}
7+
PYTORCH_DEPENDENCY_GROUP=${PYTORCH_DEPENDENCY_GROUP:-pin_pytorch_cpu}
8+
PYTORCH_TORCH_BACKEND=${PYTORCH_TORCH_BACKEND:-cpu}
59

610
# assume libdeepmd_c.tar.gz has been created
711

8-
docker run --rm -v ${SCRIPT_PATH}/../..:/root/deepmd-kit -w /root/deepmd-kit \
9-
gcc:4.9 \
10-
/bin/sh -c "tar vxzf libdeepmd_c.tar.gz \
11-
&& cd examples/infer_water \
12-
&& gcc convert_model.c -std=c99 -L ../../libdeepmd_c/lib -I ../../libdeepmd_c/include -Wl,--no-as-needed -ldeepmd_c -Wl,-rpath=../../libdeepmd_c/lib -o convert_model \
13-
&& gcc infer_water.c -std=c99 -L ../../libdeepmd_c/lib -I ../../libdeepmd_c/include -Wl,--no-as-needed -ldeepmd_c -Wl,-rpath=../../libdeepmd_c/lib -o infer_water \
14-
&& ./convert_model \
15-
&& ./infer_water"
12+
docker run --rm -v "${SCRIPT_PATH}/../..":/root/deepmd-kit -w /root/deepmd-kit \
13+
-e CHECK_PYTORCH_RUNTIME="${CHECK_PYTORCH_RUNTIME:-0}" \
14+
-e PYTHON_BIN="${PYTHON_BIN}" \
15+
-e PYTORCH_DEPENDENCY_GROUP="${PYTORCH_DEPENDENCY_GROUP}" \
16+
-e PYTORCH_TORCH_BACKEND="${PYTORCH_TORCH_BACKEND}" \
17+
"${MANYLINUX_IMAGE}" \
18+
/bin/bash -lc 'set -euo pipefail
19+
export PATH="$(dirname "${PYTHON_BIN}"):${PATH}"
20+
tar vxzf libdeepmd_c.tar.gz
21+
if [ -f libdeepmd_c/download_libtorch.sh ]; then
22+
sh -n libdeepmd_c/download_libtorch.sh
23+
fi
24+
cd examples/infer_water
25+
gcc convert_model.c -std=c99 -L ../../libdeepmd_c/lib -I ../../libdeepmd_c/include -Wl,--no-as-needed -ldeepmd_c -Wl,-rpath=../../libdeepmd_c/lib -o convert_model
26+
gcc infer_water.c -std=c99 -L ../../libdeepmd_c/lib -I ../../libdeepmd_c/include -Wl,--no-as-needed -ldeepmd_c -Wl,-rpath=../../libdeepmd_c/lib -o infer_water
27+
./convert_model
28+
./infer_water
29+
cd /root/deepmd-kit
30+
if [ "${CHECK_PYTORCH_RUNTIME}" = "1" ]; then
31+
"${PYTHON_BIN}" -m pip install uv
32+
source/install/uv_with_retry.sh pip install --python "${PYTHON_BIN}" --group "${PYTORCH_DEPENDENCY_GROUP}" --torch-backend "${PYTORCH_TORCH_BACKEND}"
33+
TORCH_RUNTIME_LIB_DIRS=$("${PYTHON_BIN}" - <<'"'"'PY'"'"'
34+
import pathlib
35+
import site
36+
import sys
37+
38+
import torch
39+
40+
dirs = [pathlib.Path(torch.__file__).resolve().parent / "lib"]
41+
roots = []
42+
try:
43+
roots.extend(site.getsitepackages())
44+
except AttributeError:
45+
pass
46+
try:
47+
roots.append(site.getusersitepackages())
48+
except AttributeError:
49+
pass
50+
roots.extend(sys.path)
51+
for root in roots:
52+
if not root:
53+
continue
54+
nvidia_dir = pathlib.Path(root) / "nvidia"
55+
if nvidia_dir.is_dir():
56+
dirs.extend(sorted(path for path in nvidia_dir.glob("*/lib") if path.is_dir()))
57+
seen = set()
58+
unique_dirs = []
59+
for path in dirs:
60+
path = path.resolve()
61+
if path in seen:
62+
continue
63+
seen.add(path)
64+
unique_dirs.append(str(path))
65+
print(":".join(unique_dirs))
66+
PY
67+
)
68+
RUNTIME_LIBRARY_PATH="${PWD}/libdeepmd_c/lib:${TORCH_RUNTIME_LIB_DIRS}"
69+
if [ -n "${LD_LIBRARY_PATH:-}" ]; then
70+
RUNTIME_LIBRARY_PATH="${RUNTIME_LIBRARY_PATH}:${LD_LIBRARY_PATH}"
71+
fi
72+
LD_LIBRARY_PATH="${RUNTIME_LIBRARY_PATH}" ldd libdeepmd_c/lib/libdeepmd_backend_pt.so > /tmp/deepmd_pt_ldd.txt
73+
LD_LIBRARY_PATH="${RUNTIME_LIBRARY_PATH}" ldd libdeepmd_c/lib/libdeepmd_backend_ptexpt.so >> /tmp/deepmd_pt_ldd.txt
74+
LD_LIBRARY_PATH="${RUNTIME_LIBRARY_PATH}" ldd libdeepmd_c/lib/libdeepmd_op_pt.so >> /tmp/deepmd_pt_ldd.txt
75+
cat /tmp/deepmd_pt_ldd.txt
76+
if grep -q "not found" /tmp/deepmd_pt_ldd.txt; then
77+
exit 1
78+
fi
79+
LD_LIBRARY_PATH="${RUNTIME_LIBRARY_PATH}" "${PYTHON_BIN}" - <<'"'"'PY'"'"'
80+
import ctypes
81+
import os
82+
import pathlib
83+
84+
import torch # noqa: F401
85+
86+
libdir = pathlib.Path("libdeepmd_c/lib").resolve()
87+
for name in [
88+
"libdeepmd_op_pt.so",
89+
"libdeepmd_backend_pt.so",
90+
"libdeepmd_backend_ptexpt.so",
91+
]:
92+
ctypes.CDLL(str(libdir / name), mode=os.RTLD_NOW | os.RTLD_LOCAL)
93+
PY
94+
fi'

0 commit comments

Comments
 (0)