From a54b50b0d9f6509d46633c9f9dad25fd88cb35d6 Mon Sep 17 00:00:00 2001 From: lishangfan Date: Thu, 25 Sep 2025 19:53:50 +0800 Subject: [PATCH] python lib path --- atvc/examples/ops_pytorch/add/README.md | 3 ++- atvc/examples/ops_pytorch/add/run.sh | 4 +++- atvc/examples/ops_pytorch/reduce_sum/README.md | 3 ++- atvc/examples/ops_pytorch/reduce_sum/run.sh | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/atvc/examples/ops_pytorch/add/README.md b/atvc/examples/ops_pytorch/add/README.md index d05f80b8..a410bbb7 100644 --- a/atvc/examples/ops_pytorch/add/README.md +++ b/atvc/examples/ops_pytorch/add/README.md @@ -119,7 +119,8 @@ z = x + y -L${torch_location}/lib \ -L${torch_npu_location}/lib \ -L${python_lib} \ - -L_ASCEND_INSTALL_PATH/lib64 \ + -L${lib_path} \ + -L${_ASCEND_INSTALL_PATH}/lib64 \ -ltorch -ltorch_cpu -lc10 -ltorch_npu -lpython3 -ltorch_python \ -shared -cce-enable-plugin --cce-aicore-arch=dav-c220 -fPIC -ltiling_api -lplatform -lm -ldl \ -o libascendc_pytorch.so diff --git a/atvc/examples/ops_pytorch/add/run.sh b/atvc/examples/ops_pytorch/add/run.sh index 217025b6..f08ce377 100644 --- a/atvc/examples/ops_pytorch/add/run.sh +++ b/atvc/examples/ops_pytorch/add/run.sh @@ -13,6 +13,7 @@ torch_location=$(python3 -c "import torch; print(torch.__path__[0])") torch_npu_location=$(python3 -c "import torch_npu; print(torch_npu.__path__[0])") python_include=$(python3 -c "import sysconfig; print(sysconfig.get_path('include'))") python_lib=$(python3 -c "import sysconfig; print(sysconfig.get_path('stdlib'))") +lib_path=$(dirname "$python_lib") export LD_LIBRARY_PATH=${torch_npu_location}/lib/:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${torch_location}/lib/:$LD_LIBRARY_PATH if [ -z "$ATVC_PATH" ]; then @@ -47,7 +48,8 @@ bisheng -x cce pytorch_ascendc_extension.cpp \ -L${torch_location}/lib \ -L${torch_npu_location}/lib \ -L${python_lib} \ - -L_ASCEND_INSTALL_PATH/lib64 \ + -L${lib_path} \ + -L${_ASCEND_INSTALL_PATH}/lib64 \ -ltorch -ltorch_cpu -lc10 -ltorch_npu -lpython3 -ltorch_python \ -shared -cce-enable-plugin --cce-aicore-arch=dav-c220 -fPIC -ltiling_api -lplatform -lm -ldl \ -o libascendc_pytorch.so diff --git a/atvc/examples/ops_pytorch/reduce_sum/README.md b/atvc/examples/ops_pytorch/reduce_sum/README.md index a61696fd..c392188b 100644 --- a/atvc/examples/ops_pytorch/reduce_sum/README.md +++ b/atvc/examples/ops_pytorch/reduce_sum/README.md @@ -147,7 +147,8 @@ ReduceSum是对输入tensor的指定轴进行规约累加的计算并输出结 -L${torch_location}/lib \ -L${torch_npu_location}/lib \ -L${python_lib} \ - -L_ASCEND_INSTALL_PATH/lib64 \ + -L${lib_path} \ + -L${_ASCEND_INSTALL_PATH}/lib64 \ -ltorch -ltorch_cpu -lc10 -ltorch_npu -lpython3 -ltorch_python \ -shared -cce-enable-plugin --cce-aicore-arch=dav-c220 -fPIC -ltiling_api -lplatform -lm -ldl \ -o libascendc_pytorch.so diff --git a/atvc/examples/ops_pytorch/reduce_sum/run.sh b/atvc/examples/ops_pytorch/reduce_sum/run.sh index 8c8c371b..d0d27305 100644 --- a/atvc/examples/ops_pytorch/reduce_sum/run.sh +++ b/atvc/examples/ops_pytorch/reduce_sum/run.sh @@ -13,6 +13,7 @@ torch_location=$(python3 -c "import torch; print(torch.__path__[0])") torch_npu_location=$(python3 -c "import torch_npu; print(torch_npu.__path__[0])") python_include=$(python3 -c "import sysconfig; print(sysconfig.get_path('include'))") python_lib=$(python3 -c "import sysconfig; print(sysconfig.get_path('stdlib'))") +lib_path=$(dirname "$python_lib") export LD_LIBRARY_PATH=${torch_npu_location}/lib/:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${torch_location}/lib/:$LD_LIBRARY_PATH if [ -z "$ATVC_PATH" ]; then @@ -47,7 +48,8 @@ bisheng -x cce pytorch_ascendc_extension.cpp \ -L${torch_location}/lib \ -L${torch_npu_location}/lib \ -L${python_lib} \ - -L_ASCEND_INSTALL_PATH/lib64 \ + -L${lib_path} \ + -L${_ASCEND_INSTALL_PATH}/lib64 \ -ltorch -ltorch_cpu -lc10 -ltorch_npu -lpython3 -ltorch_python \ -shared -cce-enable-plugin --cce-aicore-arch=dav-c220 -fPIC -ltiling_api -lplatform -lm -ldl \ -o libascendc_pytorch.so -- Gitee