Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cudnn-frontend and dirent #54461

Merged
merged 10 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions cmake/external/cudnn-frontend.cmake
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -26,21 +26,58 @@ 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()

mrcangye marked this conversation as resolved.
Show resolved Hide resolved
ExternalProject_Add(
extern_cudnn_frontend
${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
Expand Down
43 changes: 38 additions & 5 deletions cmake/external/dirent.cmake
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -17,20 +17,53 @@

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")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

win10下面使用cmake-gui编译时会因为DIRENT_CACHE_FILENAME这个变量没有设置而无法下载dirent然后报错,建议将set(DIRENT_CACHE_FILENAME "1.23.2.tar.gz")放到endif()后面,这样才能保证DIRENT_CACHE_FILENAME这个变量始终可以正确设置。

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()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果之前下载了到源码目录了,再重新执行,会再次下载吗?还是会覆盖掉?是否需要判断一下再决定下不下载呢?

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 ""
mrcangye marked this conversation as resolved.
Show resolved Hide resolved
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
Expand Down