From a20d0fe895388b3d85e3fd5c392abe06682340b9 Mon Sep 17 00:00:00 2001 From: mrcangye Date: Thu, 8 Jun 2023 15:29:53 +0800 Subject: [PATCH 01/10] add cudnn-frontend and dirent --- cmake/external/cudnn-frontend.cmake | 44 ++++++++++++++++++++++++++--- cmake/external/dirent.cmake | 40 ++++++++++++++++++++++++-- 2 files changed, 77 insertions(+), 7 deletions(-) diff --git a/cmake/external/cudnn-frontend.cmake b/cmake/external/cudnn-frontend.cmake index 10a49110f842b..af311c12d5692 100644 --- a/cmake/external/cudnn-frontend.cmake +++ b/cmake/external/cudnn-frontend.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. +# Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,21 +26,57 @@ if(CUDNN_VERSION LESS 8000) ) endif() +if((NOT DEFINED CUDNN_FRONTEND_NAME) OR (NOT DEFINED CUDNN_FRONTEND_URL)) + set(CUDNN_FRONTEND_VER + "1.23.2" + CACHE STRING "" FORCE) + set(CUDNN_FRONTEND_NAME + "cudnn-frontend" + CACHE STRING "" FORCE) + set(CUDNN_FRONTEND_URL + "https://github.com/NVIDIA/cudnn-frontend/archive/refs/tags/v0.7.1.tar.gz" + CACHE STRING "" FORCE) + set(CUDNN_FRONTEND_CACHE_FILENAME "v0.7.1.tar.gz") +endif() + +message(STATUS "CUDNN_FRONTEND_NAME: ${CUDNN_FRONTEND_NAME}, CUDNN_FRONTEND_URL: ${CUDNN_FRONTEND_URL}") +set(DIRENT_DOWNLOAD_DIR "${PADDLE_SOURCE_DIR}/third_party/cudnn-frontend") # Version: v0.7.1 set(CUDNN_FRONTEND_PREFIX_DIR ${THIRD_PARTY_PATH}/cudnn-frontend) set(CUDNN_FRONTEND_SOURCE_DIR ${THIRD_PARTY_PATH}/cudnn-frontend/src/extern_cudnn_frontend/include) -set(CUDNN_FRONTEND_REPOSITORY https://github.com/NVIDIA/cudnn-frontend.git) -set(CUDNN_FRONTEND_TAG v0.7.1) + set(CUDNN_FRONTEND_INCLUDE_DIR ${CUDNN_FRONTEND_SOURCE_DIR}) include_directories(${CUDNN_FRONTEND_INCLUDE_DIR}) message( STATUS - "Adding cudnn-frontend. Version: ${CUDNN_FRONTEND_TAG}. Directory: ${CUDNN_FRONTEND_INCLUDE_DIR}" + "Adding cudnn-frontend. Version: ${CUDNN_FRONTEND_VER}. Directory: ${DIRENT_DOWNLOAD_DIR}" ) +function(download_cudnn-frontend) + message( + STATUS + "Downloading ${CUDNN_FRONTEND_URL} to ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME}" + ) + # NOTE: If the version is updated, consider emptying the folder; maybe add timeout + file( + DOWNLOAD ${CUDNN_FRONTEND_URL} + ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME} + STATUS ERR) + if(ERR EQUAL 0) + message(STATUS "Download ${CUDNN_FRONTEND_CACHE_FILENAME} success") + else() + message( + FATAL_ERROR + "Download failed, error: ${ERR}\n You can try downloading ${CUDNN_FRONTEND_CACHE_FILENAME} again" + ) + endif() +endfunction() + +download_dirent() + ExternalProject_Add( extern_cudnn_frontend ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE} diff --git a/cmake/external/dirent.cmake b/cmake/external/dirent.cmake index 51d8eaac29e7d..06b66cab193de 100644 --- a/cmake/external/dirent.cmake +++ b/cmake/external/dirent.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. +# Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,13 +17,47 @@ include(ExternalProject) +if((NOT DEFINED DIRENT_NAME) OR (NOT DEFINED DIRENT_URL)) + set(DIRENT_VER + "1.23.2" + CACHE STRING "" FORCE) + set(DIRENT_NAME + "dirent" + CACHE STRING "" FORCE) + set(DIRENT_URL + "https://github.com/tronkko/dirent/archive/refs/tags/1.23.2.tar.gz" + CACHE STRING "" FORCE) + set(DIRENT_CACHE_FILENAME "1.23.2.tar.gz") +endif() + +message(STATUS "DIRENT_NAME: ${DIRENT_NAME}, DIRENT_URL: ${DIRENT_URL}") +set(DIRENT_DOWNLOAD_DIR "${PADDLE_SOURCE_DIR}/third_party/dirent") set(DIRENT_PREFIX_DIR ${THIRD_PARTY_PATH}/dirent) set(DIRENT_INCLUDE_DIR ${THIRD_PARTY_PATH}/dirent/src/extern_dirent/include) include_directories(${DIRENT_INCLUDE_DIR}) -set(DIRENT_REPOSITORY ${GIT_URL}/tronkko/dirent) -set(DIRENT_TAG 1.23.2) +function(download_dirent) + message( + STATUS + "Downloading ${DIRENT_URL} to ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME}" + ) + # NOTE: If the version is updated, consider emptying the folder; maybe add timeout + file( + DOWNLOAD ${DIRENT_URL} + ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME} + STATUS ERR) + if(ERR EQUAL 0) + message(STATUS "Download ${DIRENT_CACHE_FILENAME} success") + else() + message( + FATAL_ERROR + "Download failed, error: ${ERR}\n You can try downloading ${DIRENT_CACHE_FILENAME} again" + ) + endif() +endfunction() + +download_dirent() ExternalProject_Add( extern_dirent From ecc6bcfbe4ccab0a70f8f2bb79beee55998ce54e Mon Sep 17 00:00:00 2001 From: mrcangye Date: Thu, 8 Jun 2023 15:34:01 +0000 Subject: [PATCH 02/10] rewrite dirent --- cmake/external/cudnn-frontend.cmake | 13 +++++++------ cmake/external/dirent.cmake | 6 ++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cmake/external/cudnn-frontend.cmake b/cmake/external/cudnn-frontend.cmake index af311c12d5692..cab8431d3abb2 100644 --- a/cmake/external/cudnn-frontend.cmake +++ b/cmake/external/cudnn-frontend.cmake @@ -39,14 +39,16 @@ if((NOT DEFINED CUDNN_FRONTEND_NAME) OR (NOT DEFINED CUDNN_FRONTEND_URL)) set(CUDNN_FRONTEND_CACHE_FILENAME "v0.7.1.tar.gz") endif() -message(STATUS "CUDNN_FRONTEND_NAME: ${CUDNN_FRONTEND_NAME}, CUDNN_FRONTEND_URL: ${CUDNN_FRONTEND_URL}") +message( + STATUS + "CUDNN_FRONTEND_NAME: ${CUDNN_FRONTEND_NAME}, CUDNN_FRONTEND_URL: ${CUDNN_FRONTEND_URL}" +) set(DIRENT_DOWNLOAD_DIR "${PADDLE_SOURCE_DIR}/third_party/cudnn-frontend") # Version: v0.7.1 set(CUDNN_FRONTEND_PREFIX_DIR ${THIRD_PARTY_PATH}/cudnn-frontend) set(CUDNN_FRONTEND_SOURCE_DIR ${THIRD_PARTY_PATH}/cudnn-frontend/src/extern_cudnn_frontend/include) - set(CUDNN_FRONTEND_INCLUDE_DIR ${CUDNN_FRONTEND_SOURCE_DIR}) include_directories(${CUDNN_FRONTEND_INCLUDE_DIR}) @@ -61,10 +63,9 @@ function(download_cudnn-frontend) "Downloading ${CUDNN_FRONTEND_URL} to ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME}" ) # NOTE: If the version is updated, consider emptying the folder; maybe add timeout - file( - DOWNLOAD ${CUDNN_FRONTEND_URL} - ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME} - STATUS ERR) + file(DOWNLOAD ${CUDNN_FRONTEND_URL} + ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME} + STATUS ERR) if(ERR EQUAL 0) message(STATUS "Download ${CUDNN_FRONTEND_CACHE_FILENAME} success") else() diff --git a/cmake/external/dirent.cmake b/cmake/external/dirent.cmake index 06b66cab193de..9f16b992ff762 100644 --- a/cmake/external/dirent.cmake +++ b/cmake/external/dirent.cmake @@ -43,10 +43,8 @@ function(download_dirent) "Downloading ${DIRENT_URL} to ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME}" ) # NOTE: If the version is updated, consider emptying the folder; maybe add timeout - file( - DOWNLOAD ${DIRENT_URL} - ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME} - STATUS ERR) + file(DOWNLOAD ${DIRENT_URL} ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME} + STATUS ERR) if(ERR EQUAL 0) message(STATUS "Download ${DIRENT_CACHE_FILENAME} success") else() From 4b42d801eb9909a79e0ff9ec38bf151c939460b6 Mon Sep 17 00:00:00 2001 From: mrcangye Date: Fri, 9 Jun 2023 02:59:38 +0000 Subject: [PATCH 03/10] dirent --- cmake/external/dirent.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/external/dirent.cmake b/cmake/external/dirent.cmake index 9f16b992ff762..35287581363c6 100644 --- a/cmake/external/dirent.cmake +++ b/cmake/external/dirent.cmake @@ -60,9 +60,10 @@ download_dirent() ExternalProject_Add( extern_dirent ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE} - GIT_REPOSITORY ${DIRENT_REPOSITORY} - GIT_TAG ${DIRENT_TAG} + URL ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME} PREFIX ${DIRENT_PREFIX_DIR} + DOWNLOAD_DIR ${DIRENT_DOWNLOAD_DIR} + SOURCE_DIR ${DIRENT_INSTALL_DIR} UPDATE_COMMAND "" CONFIGURE_COMMAND "" BUILD_COMMAND "" From 959b7ac4f0a846d8f18df2b1206c0da7726c7c1f Mon Sep 17 00:00:00 2001 From: mrcangye Date: Tue, 13 Jun 2023 16:26:05 +0000 Subject: [PATCH 04/10] Increase download judgment. --- cmake/external/cudnn-frontend.cmake | 5 ++++- cmake/external/dirent.cmake | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cmake/external/cudnn-frontend.cmake b/cmake/external/cudnn-frontend.cmake index cab8431d3abb2..3bc3897e48ac8 100644 --- a/cmake/external/cudnn-frontend.cmake +++ b/cmake/external/cudnn-frontend.cmake @@ -76,7 +76,10 @@ function(download_cudnn-frontend) endif() endfunction() -download_dirent() +if(NOT EXISTS ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME}) + message(STATUS "Local package ${CUDNN_FRONTEND_CACHE_FILENAME} not found, starting download.") + download_cudnn-frontend() +endif() ExternalProject_Add( extern_cudnn_frontend diff --git a/cmake/external/dirent.cmake b/cmake/external/dirent.cmake index 35287581363c6..582be6f7d231f 100644 --- a/cmake/external/dirent.cmake +++ b/cmake/external/dirent.cmake @@ -55,7 +55,10 @@ function(download_dirent) endif() endfunction() -download_dirent() +if(NOT EXISTS ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME}) + message(STATUS "Local package ${DIRENT_CACHE_FILENAME} not found, starting download.") + download_dirent() +endif() ExternalProject_Add( extern_dirent From d9c34b6fb3d7988d3a24354728038345aca00873 Mon Sep 17 00:00:00 2001 From: mrcangye Date: Wed, 14 Jun 2023 02:11:19 +0000 Subject: [PATCH 05/10] rewrite cudnn-fronted --- cmake/external/cudnn-frontend.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/external/cudnn-frontend.cmake b/cmake/external/cudnn-frontend.cmake index 3bc3897e48ac8..7b782a388ecff 100644 --- a/cmake/external/cudnn-frontend.cmake +++ b/cmake/external/cudnn-frontend.cmake @@ -76,8 +76,8 @@ function(download_cudnn-frontend) endif() endfunction() -if(NOT EXISTS ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME}) - message(STATUS "Local package ${CUDNN_FRONTEND_CACHE_FILENAME} not found, starting download.") +if(NOT EXISTS ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME}) + message(STATUS "Local package ${CUDNN_FRONTEND_CACHE_FILENAME} not found, starting download.") download_cudnn-frontend() endif() From ca87b969a17c1ca3e66704594b4471be48911b51 Mon Sep 17 00:00:00 2001 From: mrcangye Date: Wed, 14 Jun 2023 02:52:35 +0000 Subject: [PATCH 06/10] rewrite dirent --- cmake/external/dirent.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/external/dirent.cmake b/cmake/external/dirent.cmake index 582be6f7d231f..33f136de4afe0 100644 --- a/cmake/external/dirent.cmake +++ b/cmake/external/dirent.cmake @@ -55,8 +55,8 @@ function(download_dirent) endif() endfunction() -if(NOT EXISTS ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME}) - message(STATUS "Local package ${DIRENT_CACHE_FILENAME} not found, starting download.") +if(NOT EXISTS ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME}) + message(STATUS "Local package ${DIRENT_CACHE_FILENAME} not found, starting download.") download_dirent() endif() From 09df96f17ebd52aebc39553fc8b5b05a9c9726c7 Mon Sep 17 00:00:00 2001 From: mrcangye Date: Thu, 15 Jun 2023 03:02:19 +0000 Subject: [PATCH 07/10] rewrite cudnn_fronted --- cmake/external/cudnn-frontend.cmake | 9 ++++++--- cmake/external/dirent.cmake | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmake/external/cudnn-frontend.cmake b/cmake/external/cudnn-frontend.cmake index 7b782a388ecff..9dab5153585da 100644 --- a/cmake/external/cudnn-frontend.cmake +++ b/cmake/external/cudnn-frontend.cmake @@ -57,7 +57,7 @@ message( "Adding cudnn-frontend. Version: ${CUDNN_FRONTEND_VER}. Directory: ${DIRENT_DOWNLOAD_DIR}" ) -function(download_cudnn-frontend) +function(download_cudnn_frontend) message( STATUS "Downloading ${CUDNN_FRONTEND_URL} to ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME}" @@ -77,8 +77,11 @@ function(download_cudnn-frontend) endfunction() if(NOT EXISTS ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME}) - message(STATUS "Local package ${CUDNN_FRONTEND_CACHE_FILENAME} not found, starting download.") - download_cudnn-frontend() + message( + STATUS + "Local package ${CUDNN_FRONTEND_CACHE_FILENAME} not found, starting download." + ) + download_cudnn_frontend() endif() ExternalProject_Add( diff --git a/cmake/external/dirent.cmake b/cmake/external/dirent.cmake index 33f136de4afe0..21f65c263045c 100644 --- a/cmake/external/dirent.cmake +++ b/cmake/external/dirent.cmake @@ -56,7 +56,9 @@ function(download_dirent) endfunction() if(NOT EXISTS ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME}) - message(STATUS "Local package ${DIRENT_CACHE_FILENAME} not found, starting download.") + message( + STATUS + "Local package ${DIRENT_CACHE_FILENAME} not found, starting download.") download_dirent() endif() From 9c205acf9453354b89936baadfa0c815cbc569e6 Mon Sep 17 00:00:00 2001 From: mrcangye Date: Thu, 15 Jun 2023 09:14:59 +0000 Subject: [PATCH 08/10] rewrite --- cmake/external/cudnn-frontend.cmake | 34 +++++++++++++++++++---------- cmake/external/dirent.cmake | 23 +++++++++++++------ 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/cmake/external/cudnn-frontend.cmake b/cmake/external/cudnn-frontend.cmake index 9dab5153585da..ddfc4e2679504 100644 --- a/cmake/external/cudnn-frontend.cmake +++ b/cmake/external/cudnn-frontend.cmake @@ -38,6 +38,7 @@ if((NOT DEFINED CUDNN_FRONTEND_NAME) OR (NOT DEFINED CUDNN_FRONTEND_URL)) CACHE STRING "" FORCE) set(CUDNN_FRONTEND_CACHE_FILENAME "v0.7.1.tar.gz") endif() +set(CUDNN_FRONTEND_URL_MD5 "d8f911df571f8b0d40226efa9c0150c8") message( STATUS @@ -48,7 +49,7 @@ set(DIRENT_DOWNLOAD_DIR "${PADDLE_SOURCE_DIR}/third_party/cudnn-frontend") set(CUDNN_FRONTEND_PREFIX_DIR ${THIRD_PARTY_PATH}/cudnn-frontend) set(CUDNN_FRONTEND_SOURCE_DIR ${THIRD_PARTY_PATH}/cudnn-frontend/src/extern_cudnn_frontend/include) - +set(CUSPARSELT_INSTALL_DIR ${THIRD_PARTY_PATH}/install/cudnn-frontend) set(CUDNN_FRONTEND_INCLUDE_DIR ${CUDNN_FRONTEND_SOURCE_DIR}) include_directories(${CUDNN_FRONTEND_INCLUDE_DIR}) @@ -63,9 +64,11 @@ function(download_cudnn_frontend) "Downloading ${CUDNN_FRONTEND_URL} to ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME}" ) # NOTE: If the version is updated, consider emptying the folder; maybe add timeout - file(DOWNLOAD ${CUDNN_FRONTEND_URL} - ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME} - STATUS ERR) + file( + DOWNLOAD ${CUDNN_FRONTEND_URL} + ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME} + EXPECTED_MD5 ${CUDNN_FRONTEND_URL_MD5} + STATUS ERR) if(ERR EQUAL 0) message(STATUS "Download ${CUDNN_FRONTEND_CACHE_FILENAME} success") else() @@ -76,20 +79,27 @@ function(download_cudnn_frontend) endif() endfunction() -if(NOT EXISTS ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME}) - message( - STATUS - "Local package ${CUDNN_FRONTEND_CACHE_FILENAME} not found, starting download." - ) +if(EXISTS ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME}) + file(MD5 ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME} + CUDNN_FRONTEND_MD5) + if(NOT CUDNN_FRONTEND_MD5 STREQUAL CUDNN_FRONTEND_URL_MD5) + # clean build file + file(REMOVE_RECURSE ${CUDNN_FRONTEND_PREFIX_DIR}) + file(REMOVE_RECURSE ${CUDNN_FRONTEND_INSTALL_DIR}) + download_cudnn_frontend() + endif() +else() download_cudnn_frontend() endif() ExternalProject_Add( extern_cudnn_frontend - ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE} - GIT_REPOSITORY ${CUDNN_FRONTEND_REPOSITORY} - GIT_TAG ${CUDNN_FRONTEND_TAG} + ${EXTERNAL_PROJECT_LOG_ARGS} + URL ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME} PREFIX ${CUDNN_FRONTEND_PREFIX_DIR} + DOWNLOAD_DIR ${CUDNN_FRONTEND_DOWNLOAD_DIR} + DOWNLOAD_NO_PROGRESS 1 + SOURCE_DIR ${CUDNN_FRONTEND_INSTALL_DIR} UPDATE_COMMAND "" PATCH_COMMAND patch -d ${CUDNN_FRONTEND_SOURCE_DIR} -p2 < diff --git a/cmake/external/dirent.cmake b/cmake/external/dirent.cmake index 21f65c263045c..fb163eda4e5d2 100644 --- a/cmake/external/dirent.cmake +++ b/cmake/external/dirent.cmake @@ -34,6 +34,7 @@ message(STATUS "DIRENT_NAME: ${DIRENT_NAME}, DIRENT_URL: ${DIRENT_URL}") set(DIRENT_DOWNLOAD_DIR "${PADDLE_SOURCE_DIR}/third_party/dirent") set(DIRENT_PREFIX_DIR ${THIRD_PARTY_PATH}/dirent) set(DIRENT_INCLUDE_DIR ${THIRD_PARTY_PATH}/dirent/src/extern_dirent/include) +set(CUDNN_FRONTEND_URL_MD5 "6bf6319ae71432ed6a4d90dc61e80131") include_directories(${DIRENT_INCLUDE_DIR}) @@ -43,8 +44,10 @@ function(download_dirent) "Downloading ${DIRENT_URL} to ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME}" ) # NOTE: If the version is updated, consider emptying the folder; maybe add timeout - file(DOWNLOAD ${DIRENT_URL} ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME} - STATUS ERR) + file( + DOWNLOAD ${DIRENT_URL} ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME} + EXPECTED_MD5 ${DIRENT_URL_MD5} + STATUS ERR) if(ERR EQUAL 0) message(STATUS "Download ${DIRENT_CACHE_FILENAME} success") else() @@ -55,19 +58,25 @@ function(download_dirent) endif() endfunction() -if(NOT EXISTS ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME}) - message( - STATUS - "Local package ${DIRENT_CACHE_FILENAME} not found, starting download.") +if(EXISTS ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME}) + file(MD5 ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME} DIRENT_MD5) + if(NOT DIRENT_MD5 STREQUAL DIRENT_URL_MD5) + # clean build file + file(REMOVE_RECURSE ${DIRENT_PREFIX_DIR}) + file(REMOVE_RECURSE ${DIRENT_INSTALL_DIR}) + download_dirent() + endif() +else() download_dirent() endif() ExternalProject_Add( extern_dirent - ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE} + ${EXTERNAL_PROJECT_LOG_ARGS} URL ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME} PREFIX ${DIRENT_PREFIX_DIR} DOWNLOAD_DIR ${DIRENT_DOWNLOAD_DIR} + DOWNLOAD_NO_PROGRESS 1 SOURCE_DIR ${DIRENT_INSTALL_DIR} UPDATE_COMMAND "" CONFIGURE_COMMAND "" From 9c4e027c76ed5ab787cb9db6bfdb10bca6b1f06e Mon Sep 17 00:00:00 2001 From: mrcangye Date: Thu, 15 Jun 2023 15:24:20 +0000 Subject: [PATCH 09/10] rewrite dirent --- cmake/external/dirent.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/external/dirent.cmake b/cmake/external/dirent.cmake index fb163eda4e5d2..78e8465772198 100644 --- a/cmake/external/dirent.cmake +++ b/cmake/external/dirent.cmake @@ -34,7 +34,7 @@ message(STATUS "DIRENT_NAME: ${DIRENT_NAME}, DIRENT_URL: ${DIRENT_URL}") set(DIRENT_DOWNLOAD_DIR "${PADDLE_SOURCE_DIR}/third_party/dirent") set(DIRENT_PREFIX_DIR ${THIRD_PARTY_PATH}/dirent) set(DIRENT_INCLUDE_DIR ${THIRD_PARTY_PATH}/dirent/src/extern_dirent/include) -set(CUDNN_FRONTEND_URL_MD5 "6bf6319ae71432ed6a4d90dc61e80131") +set(DIRENT_URL_MD5 "6bf6319ae71432ed6a4d90dc61e80131") include_directories(${DIRENT_INCLUDE_DIR}) From 54e67fc1cc436996322f7ccca63d710e4a1d7d38 Mon Sep 17 00:00:00 2001 From: mrcangye Date: Sun, 18 Jun 2023 01:25:03 +0000 Subject: [PATCH 10/10] rewrite --- cmake/external/cudnn-frontend.cmake | 2 -- cmake/external/dirent.cmake | 2 -- 2 files changed, 4 deletions(-) diff --git a/cmake/external/cudnn-frontend.cmake b/cmake/external/cudnn-frontend.cmake index ddfc4e2679504..5ba038d457d54 100644 --- a/cmake/external/cudnn-frontend.cmake +++ b/cmake/external/cudnn-frontend.cmake @@ -85,7 +85,6 @@ if(EXISTS ${CUDNN_FRONTEND_DOWNLOAD_DIR}/${CUDNN_FRONTEND_CACHE_FILENAME}) if(NOT CUDNN_FRONTEND_MD5 STREQUAL CUDNN_FRONTEND_URL_MD5) # clean build file file(REMOVE_RECURSE ${CUDNN_FRONTEND_PREFIX_DIR}) - file(REMOVE_RECURSE ${CUDNN_FRONTEND_INSTALL_DIR}) download_cudnn_frontend() endif() else() @@ -99,7 +98,6 @@ ExternalProject_Add( PREFIX ${CUDNN_FRONTEND_PREFIX_DIR} DOWNLOAD_DIR ${CUDNN_FRONTEND_DOWNLOAD_DIR} DOWNLOAD_NO_PROGRESS 1 - SOURCE_DIR ${CUDNN_FRONTEND_INSTALL_DIR} UPDATE_COMMAND "" PATCH_COMMAND patch -d ${CUDNN_FRONTEND_SOURCE_DIR} -p2 < diff --git a/cmake/external/dirent.cmake b/cmake/external/dirent.cmake index 78e8465772198..9c212a237f0a4 100644 --- a/cmake/external/dirent.cmake +++ b/cmake/external/dirent.cmake @@ -63,7 +63,6 @@ if(EXISTS ${DIRENT_DOWNLOAD_DIR}/${DIRENT_CACHE_FILENAME}) if(NOT DIRENT_MD5 STREQUAL DIRENT_URL_MD5) # clean build file file(REMOVE_RECURSE ${DIRENT_PREFIX_DIR}) - file(REMOVE_RECURSE ${DIRENT_INSTALL_DIR}) download_dirent() endif() else() @@ -77,7 +76,6 @@ ExternalProject_Add( PREFIX ${DIRENT_PREFIX_DIR} DOWNLOAD_DIR ${DIRENT_DOWNLOAD_DIR} DOWNLOAD_NO_PROGRESS 1 - SOURCE_DIR ${DIRENT_INSTALL_DIR} UPDATE_COMMAND "" CONFIGURE_COMMAND "" BUILD_COMMAND ""