-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core][pruning][feature] cuSPARSELt build integration (#103700)
Summary: This stack of PR's integrates cuSPARSELt into PyTorch. This PR adds support for cuSPARSELt into the build process. It adds in a new flag, USE_CUSPARSELT that defaults to false. When USE_CUSPASRELT=1 is specified, the user can also specify CUSPASRELT_ROOT, which defines the path to the library. Compiling pytorch with cusparselt support can be done as follows: `` USE_CUSPARSELT=1 CUSPARSELT_ROOT=/path/to/cusparselt python setup.py develop ``` Test Plan: Reviewers: Subscribers: Tasks: Tags: Pull Request resolved: #103700 Approved by: https://github.com/albanD
- Loading branch information
1 parent
d83b887
commit f81f909
Showing
11 changed files
with
119 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Find the CUSPARSELT library | ||
# | ||
# The following variables are optionally searched for defaults | ||
# CUSPARSELT_ROOT: Base directory where CUSPARSELT is found | ||
# CUSPARSELT_INCLUDE_DIR: Directory where CUSPARSELT header is searched for | ||
# CUSPARSELT_LIBRARY: Directory where CUSPARSELT library is searched for | ||
# | ||
# The following are set after configuration is done: | ||
# CUSPARSELT_FOUND | ||
# CUSPARSELT_INCLUDE_PATH | ||
# CUSPARSELT_LIBRARY_PATH | ||
|
||
include(FindPackageHandleStandardArgs) | ||
|
||
set(CUSPARSELT_ROOT $ENV{CUSPARSELT_ROOT_DIR} CACHE PATH "Folder containing NVIDIA cuSPARSELt") | ||
if (DEFINED $ENV{CUSPARSELT_ROOT_DIR}) | ||
message(WARNING "CUSPARSELT_ROOT_DIR is deprecated. Please set CUSPARSELT_ROOT instead.") | ||
endif() | ||
list(APPEND CUSPARSELT_ROOT $ENV{CUSPARSELT_ROOT_DIR} ${CUDA_TOOLKIT_ROOT_DIR}) | ||
|
||
# Compatible layer for CMake <3.12. CUSPARSELT_ROOT will be accounted in for searching paths and libraries for CMake >=3.12. | ||
list(APPEND CMAKE_PREFIX_PATH ${CUSPARSELT_ROOT}) | ||
|
||
set(CUSPARSELT_INCLUDE_DIR $ENV{CUSPARSELT_INCLUDE_DIR} CACHE PATH "Folder containing NVIDIA cuSPARSELt header files") | ||
|
||
find_path(CUSPARSELT_INCLUDE_PATH cusparseLt.h | ||
HINTS ${CUSPARSELT_INCLUDE_DIR} | ||
PATH_SUFFIXES cuda/include cuda include) | ||
|
||
set(CUSPARSELT_LIBRARY $ENV{CUSPARSELT_LIBRARY} CACHE PATH "Path to the cusparselt library file (e.g., libcusparseLt.so)") | ||
|
||
find_library(CUSPARSELT_LIBRARY_PATH libcusparseLt.so | ||
PATHS ${CUSPARSELT_LIBRARY} | ||
PATH_SUFFIXES lib lib64 cuda/lib cuda/lib64 lib/x64) | ||
|
||
find_package_handle_standard_args(CUSPARSELT DEFAULT_MSG CUSPARSELT_LIBRARY_PATH CUSPARSELT_INCLUDE_PATH) | ||
|
||
if(CUSPARSELT_FOUND) | ||
# Get cuSPARSELt version | ||
file(READ ${CUSPARSELT_INCLUDE_PATH}/cusparseLt.h CUSPARSELT_HEADER_CONTENTS) | ||
string(REGEX MATCH "define CUSPARSELT_VER_MAJOR * +([0-9]+)" | ||
CUSPARSELT_VERSION_MAJOR "${CUSPARSELT_HEADER_CONTENTS}") | ||
string(REGEX REPLACE "define CUSPARSELT_VER_MAJOR * +([0-9]+)" "\\1" | ||
CUSPARSELT_VERSION_MAJOR "${CUSPARSELT_VERSION_MAJOR}") | ||
string(REGEX MATCH "define CUSPARSELT_VER_MINOR * +([0-9]+)" | ||
CUSPARSELT_VERSION_MINOR "${CUSPARSELT_HEADER_CONTENTS}") | ||
string(REGEX REPLACE "define CUSPARSELT_VER_MINOR * +([0-9]+)" "\\1" | ||
CUSPARSELT_VERSION_MINOR "${CUSPARSELT_VERSION_MINOR}") | ||
string(REGEX MATCH "define CUSPARSELT_VER_PATCH * +([0-9]+)" | ||
CUSPARSELT_VERSION_PATCH "${CUSPARSELT_HEADER_CONTENTS}") | ||
string(REGEX REPLACE "define CUSPARSELT_VER_PATCH * +([0-9]+)" "\\1" | ||
CUSPARSELT_VERSION_PATCH "${CUSPARSELT_VERSION_PATCH}") | ||
# Assemble cuSPARSELt version. Use minor version since current major version is 0. | ||
if(NOT CUSPARSELT_VERSION_MINOR) | ||
set(CUSPARSELT_VERSION "?") | ||
else() | ||
set(CUSPARSELT_VERSION | ||
"${CUSPARSELT_VERSION_MAJOR}.${CUSPARSELT_VERSION_MINOR}.${CUSPARSELT_VERSION_PATCH}") | ||
endif() | ||
endif() | ||
|
||
mark_as_advanced(CUSPARSELT_ROOT CUSPARSELT_INCLUDE_DIR CUSPARSELT_LIBRARY CUSPARSELT_VERSION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters