未验证 提交 1a404657 编写于 作者: P pangyoki 提交者: GitHub

add cuDNN dynamic-link libraries into wheel package (#47552)

* add cudnn into whl package

* add cudnn dso into whl package

* let WITH_CUDNN_DSO be consistent with WITH_GPU

* fix WITH_CUDNN_DSO in paddle_build
上级 aa342a2d
......@@ -307,6 +307,8 @@ option(WITH_FLPS "FL PS mode" OFF)
option(WITH_RPC "Compile with rpc support" ${WITH_DISTRIBUTE})
option(WITH_CUDNN_FRONTEND
"Compile with CUDNN Frontend API support (experimental)" OFF)
option(WITH_CUDNN_DSO "Compile PaddlePaddle with cuDNN dynamic-link libraries"
${WITH_GPU})
if(WITH_RECORD_BUILDTIME)
set_property(
......@@ -390,6 +392,16 @@ if(NOT WITH_GPU AND WITH_NCCL)
CACHE STRING "Disable NCCL when compiling without GPU" FORCE)
endif()
if(NOT WITH_GPU AND WITH_CUDNN_DSO)
message(
WARNING
"Can't compile with cuDNN libraries when compiling without GPU. Force WITH_CUDNN_DSO=OFF."
)
set(WITH_CUDNN_DSO
OFF
CACHE STRING "Disable cuDNN libraries when compiling without GPU" FORCE)
endif()
# force WITH_XPU on when WITH_XPU_KP
if(WITH_XPU_KP AND NOT WITH_XPU)
message(
......
......@@ -197,6 +197,8 @@ function cmake_base() {
INFERENCE_DEMO_INSTALL_DIR=${INFERENCE_DEMO_INSTALL_DIR:-/root/.cache/inference_demo}
fi
WITH_CUDNN_DSO=${WITH_GPU:-OFF}
distibuted_flag=${WITH_DISTRIBUTE:-OFF}
gloo_flag=${distibuted_flag}
......@@ -214,6 +216,7 @@ function cmake_base() {
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release}
${PYTHON_FLAGS}
-DWITH_GPU=${WITH_GPU:-OFF}
-DWITH_CUDNN_DSO=${WITH_CUDNN_DSO:-OFF}
-DWITH_TENSORRT=${WITH_TENSORRT:-ON}
-DWITH_ROCM=${WITH_ROCM:-OFF}
-DWITH_CINN=${WITH_CINN:-OFF}
......@@ -269,6 +272,7 @@ EOF
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release} \
${PYTHON_FLAGS} \
-DWITH_GPU=${WITH_GPU:-OFF} \
-DWITH_CUDNN_DSO=${WITH_CUDNN_DSO:-OFF} \
-DWITH_TENSORRT=${WITH_TENSORRT:-ON} \
-DWITH_ROCM=${WITH_ROCM:-OFF} \
-DWITH_CINN=${WITH_CINN:-OFF} \
......
......@@ -8,6 +8,7 @@ import sys
import fnmatch
import errno
import platform
import glob
from contextlib import contextmanager
from setuptools import Command
......@@ -471,6 +472,19 @@ shutil.copy('${BLAS_LIB}', libs_path)
shutil.copy('${LAPACK_LIB}', libs_path)
shutil.copy('${GFORTRAN_LIB}', libs_path)
shutil.copy('${GNU_RT_LIB_1}', libs_path)
if '${WITH_CUDNN_DSO}' == 'ON' and os.path.exists('${CUDNN_LIBRARY}'):
package_data['paddle.libs']+=[os.path.basename('${CUDNN_LIBRARY}')]
shutil.copy('${CUDNN_LIBRARY}', libs_path)
if sys.platform.startswith("linux") and '${CUDNN_MAJOR_VERSION}' == '8':
# libcudnn.so includes libcudnn_ops_infer.so, libcudnn_ops_train.so,
# libcudnn_cnn_infer.so, libcudnn_cnn_train.so, libcudnn_adv_infer.so,
# libcudnn_adv_train.so
cudnn_lib_files = glob.glob(os.path.dirname('${CUDNN_LIBRARY}') + '/libcudnn_*so.8')
for cudnn_lib in cudnn_lib_files:
if os.path.exists(cudnn_lib):
package_data['paddle.libs']+=[os.path.basename(cudnn_lib)]
shutil.copy(cudnn_lib, libs_path)
if not sys.platform.startswith("linux"):
package_data['paddle.libs']+=[os.path.basename('${GNU_RT_LIB_2}')]
shutil.copy('${GNU_RT_LIB_2}', libs_path)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册