未验证 提交 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) ...@@ -307,6 +307,8 @@ option(WITH_FLPS "FL PS mode" OFF)
option(WITH_RPC "Compile with rpc support" ${WITH_DISTRIBUTE}) option(WITH_RPC "Compile with rpc support" ${WITH_DISTRIBUTE})
option(WITH_CUDNN_FRONTEND option(WITH_CUDNN_FRONTEND
"Compile with CUDNN Frontend API support (experimental)" OFF) "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) if(WITH_RECORD_BUILDTIME)
set_property( set_property(
...@@ -390,6 +392,16 @@ if(NOT WITH_GPU AND WITH_NCCL) ...@@ -390,6 +392,16 @@ if(NOT WITH_GPU AND WITH_NCCL)
CACHE STRING "Disable NCCL when compiling without GPU" FORCE) CACHE STRING "Disable NCCL when compiling without GPU" FORCE)
endif() 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 # force WITH_XPU on when WITH_XPU_KP
if(WITH_XPU_KP AND NOT WITH_XPU) if(WITH_XPU_KP AND NOT WITH_XPU)
message( message(
......
...@@ -197,6 +197,8 @@ function cmake_base() { ...@@ -197,6 +197,8 @@ function cmake_base() {
INFERENCE_DEMO_INSTALL_DIR=${INFERENCE_DEMO_INSTALL_DIR:-/root/.cache/inference_demo} INFERENCE_DEMO_INSTALL_DIR=${INFERENCE_DEMO_INSTALL_DIR:-/root/.cache/inference_demo}
fi fi
WITH_CUDNN_DSO=${WITH_GPU:-OFF}
distibuted_flag=${WITH_DISTRIBUTE:-OFF} distibuted_flag=${WITH_DISTRIBUTE:-OFF}
gloo_flag=${distibuted_flag} gloo_flag=${distibuted_flag}
...@@ -214,6 +216,7 @@ function cmake_base() { ...@@ -214,6 +216,7 @@ function cmake_base() {
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release}
${PYTHON_FLAGS} ${PYTHON_FLAGS}
-DWITH_GPU=${WITH_GPU:-OFF} -DWITH_GPU=${WITH_GPU:-OFF}
-DWITH_CUDNN_DSO=${WITH_CUDNN_DSO:-OFF}
-DWITH_TENSORRT=${WITH_TENSORRT:-ON} -DWITH_TENSORRT=${WITH_TENSORRT:-ON}
-DWITH_ROCM=${WITH_ROCM:-OFF} -DWITH_ROCM=${WITH_ROCM:-OFF}
-DWITH_CINN=${WITH_CINN:-OFF} -DWITH_CINN=${WITH_CINN:-OFF}
...@@ -269,6 +272,7 @@ EOF ...@@ -269,6 +272,7 @@ EOF
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release} \ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release} \
${PYTHON_FLAGS} \ ${PYTHON_FLAGS} \
-DWITH_GPU=${WITH_GPU:-OFF} \ -DWITH_GPU=${WITH_GPU:-OFF} \
-DWITH_CUDNN_DSO=${WITH_CUDNN_DSO:-OFF} \
-DWITH_TENSORRT=${WITH_TENSORRT:-ON} \ -DWITH_TENSORRT=${WITH_TENSORRT:-ON} \
-DWITH_ROCM=${WITH_ROCM:-OFF} \ -DWITH_ROCM=${WITH_ROCM:-OFF} \
-DWITH_CINN=${WITH_CINN:-OFF} \ -DWITH_CINN=${WITH_CINN:-OFF} \
......
...@@ -8,6 +8,7 @@ import sys ...@@ -8,6 +8,7 @@ import sys
import fnmatch import fnmatch
import errno import errno
import platform import platform
import glob
from contextlib import contextmanager from contextlib import contextmanager
from setuptools import Command from setuptools import Command
...@@ -471,6 +472,19 @@ shutil.copy('${BLAS_LIB}', libs_path) ...@@ -471,6 +472,19 @@ shutil.copy('${BLAS_LIB}', libs_path)
shutil.copy('${LAPACK_LIB}', libs_path) shutil.copy('${LAPACK_LIB}', libs_path)
shutil.copy('${GFORTRAN_LIB}', libs_path) shutil.copy('${GFORTRAN_LIB}', libs_path)
shutil.copy('${GNU_RT_LIB_1}', 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"): if not sys.platform.startswith("linux"):
package_data['paddle.libs']+=[os.path.basename('${GNU_RT_LIB_2}')] package_data['paddle.libs']+=[os.path.basename('${GNU_RT_LIB_2}')]
shutil.copy('${GNU_RT_LIB_2}', libs_path) 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.
先完成此消息的编辑!
想要评论请 注册