Skip to content

Commit

Permalink
Remove FAISS dependency, inherit other common dependencies from raft (#…
Browse files Browse the repository at this point in the history
…1863)

Originally this PR was about building FAISS shared libs via CPM, but @rlratzel mentioned cuGraph doesn't need FAISS anymore, and it'd be better if we remove it.

If we need FAISS again in the future, we can add `faiss::faiss` back to `target_link_libraries` without needing extra CPM configuration as it will be available [via raft](rapidsai/raft#345).

Edit: Removed more dependencies that we inherit from raft and/or rmm. Depends on rapidsai/raft#345.

Edit 2: I think the CUDA 11.0 thrust issue will be solved by rapidsai/rapids-cmake#98

Authors:
  - Paul Taylor (https://github.com/trxcllnt)
  - Divye Gala (https://github.com/divyegala)

Approvers:
  - Brad Rees (https://github.com/BradReesWork)
  - AJ Schmidt (https://github.com/ajschmidt8)

URL: #1863
  • Loading branch information
trxcllnt authored Jan 23, 2022
1 parent f4b5f3d commit bae28f7
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 320 deletions.
32 changes: 10 additions & 22 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Copyright (c) 2019-2022, NVIDIA CORPORATION.

# cugraph build script

Expand All @@ -20,7 +20,7 @@ REPODIR=$(cd $(dirname $0); pwd)
LIBCUGRAPH_BUILD_DIR=${LIBCUGRAPH_BUILD_DIR:=${REPODIR}/cpp/build}
LIBCUGRAPH_ETL_BUILD_DIR=${LIBCUGRAPH_ETL_BUILD_DIR:=${REPODIR}/cpp/libcugraph_etl/build}

VALIDARGS="clean uninstall libcugraph libcugraph_etl cugraph pylibcugraph cpp-mgtests docs -v -g -n --allgpuarch --buildfaiss --show_depr_warn --skip_cpp_tests -h --help"
VALIDARGS="clean uninstall libcugraph libcugraph_etl cugraph pylibcugraph cpp-mgtests docs -v -g -n --allgpuarch --skip_cpp_tests -h --help"
HELP="$0 [<target> ...] [<flag> ...]
where <target> is:
clean - remove all existing build artifacts and configuration (start over)
Expand All @@ -36,9 +36,7 @@ HELP="$0 [<target> ...] [<flag> ...]
-g - build for debug
-n - do not install after a successful build
--allgpuarch - build for all supported GPU architectures
--buildfaiss - build faiss statically into cugraph
--show_depr_warn - show cmake deprecation warnings
--skip_cpp_tests - do not build the SG test binaries as part of the libcugraph and libcugraph_etl targets
--skip_cpp_tests - do not build the SG test binaries as part of the libcugraph target
-h - print this text
default action (no args) is to build and install 'libcugraph' then 'libcugraph_etl' then 'pylibcugraph' then 'cugraph' then 'docs' targets
Expand All @@ -54,10 +52,8 @@ BUILD_DIRS="${LIBCUGRAPH_BUILD_DIR} ${LIBCUGRAPH_ETL_BUILD_DIR} ${CUGRAPH_BUILD_
VERBOSE_FLAG=""
BUILD_TYPE=Release
INSTALL_TARGET=install
BUILD_DISABLE_DEPRECATION_WARNING=ON
BUILD_CPP_TESTS=ON
BUILD_CPP_MG_TESTS=OFF
BUILD_STATIC_FAISS=OFF
BUILD_ALL_GPU_ARCH=0

# Set defaults for vars that may not have been defined externally
Expand Down Expand Up @@ -103,12 +99,6 @@ fi
if hasArg --allgpuarch; then
BUILD_ALL_GPU_ARCH=1
fi
if hasArg --buildfaiss; then
BUILD_STATIC_FAISS=ON
fi
if hasArg --show_depr_warn; then
BUILD_DISABLE_DEPRECATION_WARNING=OFF
fi
if hasArg --skip_cpp_tests; then
BUILD_CPP_TESTS=OFF
fi
Expand Down Expand Up @@ -180,14 +170,13 @@ if buildAll || hasArg libcugraph; then
fi
mkdir -p ${LIBCUGRAPH_BUILD_DIR}
cd ${LIBCUGRAPH_BUILD_DIR}
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
cmake -B "${LIBCUGRAPH_BUILD_DIR}" -S "${REPODIR}/cpp" \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DCMAKE_CUDA_ARCHITECTURES=${CUGRAPH_CMAKE_CUDA_ARCHITECTURES} \
-DDISABLE_DEPRECATION_WARNING=${BUILD_DISABLE_DEPRECATION_WARNING} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DBUILD_STATIC_FAISS=${BUILD_STATIC_FAISS} \
-DBUILD_TESTS=${BUILD_CPP_TESTS} \
-DBUILD_CUGRAPH_MG_TESTS=${BUILD_CPP_MG_TESTS} \
${REPODIR}/cpp
-DBUILD_CUGRAPH_MG_TESTS=${BUILD_CPP_MG_TESTS}

cmake --build "${LIBCUGRAPH_BUILD_DIR}" -j${PARALLEL_LEVEL} --target ${INSTALL_TARGET} ${VERBOSE_FLAG}
fi

Expand Down Expand Up @@ -242,10 +231,9 @@ if buildAll || hasArg docs; then
if [ ! -d ${LIBCUGRAPH_BUILD_DIR} ]; then
mkdir -p ${LIBCUGRAPH_BUILD_DIR}
cd ${LIBCUGRAPH_BUILD_DIR}
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DDISABLE_DEPRECATION_WARNING=${BUILD_DISABLE_DEPRECATION_WARNING} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${REPODIR}/cpp \
-DBUILD_STATIC_FAISS=${BUILD_STATIC_FAISS}
cmake -B "${LIBCUGRAPH_BUILD_DIR}" -S "${REPODIR}/cpp" \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE}
fi
cd ${LIBCUGRAPH_BUILD_DIR}
cmake --build "${LIBCUGRAPH_BUILD_DIR}" -j${PARALLEL_LEVEL} --target docs_cugraph ${VERBOSE_FLAG}
Expand Down
13 changes: 1 addition & 12 deletions ci/gpu/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Copyright (c) 2018-2021, NVIDIA CORPORATION.
# Copyright (c) 2018-2022, NVIDIA CORPORATION.
##########################################
# cuGraph GPU build & testscript for CI #
##########################################
Expand Down Expand Up @@ -94,17 +94,6 @@ if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then
gpuci_logger "Build from source"
$WORKSPACE/build.sh -v clean libcugraph pylibcugraph cugraph
else
# ...cugraph/cpu/conda_work/... is the dir name when only 1 lib* library is
# present. For multiple libs (ie. libcugraph and libcugraph_etl), the
# "_work" dir is prefixed with the lib name.
export LIBCUGRAPH_BUILD_DIR="$WORKSPACE/ci/artifacts/cugraph/cpu/libcugraph_work/cpp/build"

# Faiss patch
echo "Update libcugraph.so"
cd $LIBCUGRAPH_BUILD_DIR
chrpath -d libcugraph.so
patchelf --replace-needed `patchelf --print-needed libcugraph.so | grep faiss` libfaiss.so libcugraph.so

CONDA_FILE=`find ${CONDA_ARTIFACT_PATH} -name "libcugraph*.tar.bz2"`
CONDA_FILE=`basename "$CONDA_FILE" .tar.bz2` #get filename without extension
CONDA_FILE=${CONDA_FILE//-/=} #convert to conda install
Expand Down
2 changes: 0 additions & 2 deletions conda/environments/cugraph_dev_cuda11.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ dependencies:
- boost
- cython>=0.29,<0.30
- pytest
- libfaiss=1.7.0
- faiss-proc=*=cuda
- scikit-learn>=0.23.1
- sphinx
- pydata-sphinx-theme
Expand Down
2 changes: 0 additions & 2 deletions conda/environments/cugraph_dev_cuda11.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ dependencies:
- boost
- cython>=0.29,<0.30
- pytest
- libfaiss=1.7.0
- faiss-proc=*=cuda
- scikit-learn>=0.23.1
- sphinx
- pydata-sphinx-theme
Expand Down
2 changes: 0 additions & 2 deletions conda/environments/cugraph_dev_cuda11.4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ dependencies:
- boost
- cython>=0.29,<0.30
- pytest
- libfaiss=1.7.0
- faiss-proc=*=cuda
- scikit-learn>=0.23.1
- sphinx
- pydata-sphinx-theme
Expand Down
2 changes: 0 additions & 2 deletions conda/environments/cugraph_dev_cuda11.5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ dependencies:
- boost
- cython>=0.29,<0.30
- pytest
- libfaiss=1.7.0
- faiss-proc=*=cuda
- scikit-learn>=0.23.1
- sphinx
- pydata-sphinx-theme
Expand Down
6 changes: 1 addition & 5 deletions conda/recipes/libcugraph/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2018-2021, NVIDIA CORPORATION.
# Copyright (c) 2018-2022, NVIDIA CORPORATION.

# Usage:
# conda build -c nvidia -c rapidsai -c conda-forge .
Expand Down Expand Up @@ -42,14 +42,10 @@ requirements:
- ucx-proc=*=gpu
- gtest
- gmock
- faiss-proc=*=cuda
- libfaiss 1.7.0 *_cuda
run:
- {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }}
- nccl>=2.9.9
- ucx-proc=*=gpu
- faiss-proc=*=cuda
- libfaiss 1.7.0 *_cuda
- libcusolver>=11.2.1

about:
Expand Down
63 changes: 24 additions & 39 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ endforeach()
# arch > 86
list(POP_BACK usable_arch_values latest_arch)
list(TRANSFORM usable_arch_values APPEND "-real")
list(APPEND usable_arch_values ${latest_arch})
if (usable_arch_values)
list(APPEND usable_arch_values ${latest_arch})
else()
list(APPEND usable_arch_values ${latest_arch}-real)
endif()

set(CMAKE_CUDA_ARCHITECTURES ${usable_arch_values})

Expand All @@ -73,8 +77,6 @@ rapids_cmake_build_type(Release)
# - User Options --------------------------------------------------------------

option(BUILD_CUGRAPH_MG_TESTS "Build cuGraph multigpu algorithm tests" OFF)
set(BLAS_LIBRARIES "" CACHE STRING "Location of BLAS library for FAISS build.")
option(BUILD_STATIC_FAISS "Build the FAISS library for nearest neighbors search on GPU" OFF)
option(CMAKE_CUDA_LINEINFO "Enable the -lineinfo option for nvcc (useful for cuda-memcheck / profiler" OFF)
option(BUILD_TESTS "Configure CMake to build tests" ON)

Expand Down Expand Up @@ -122,29 +124,29 @@ if(OpenMP_FOUND)
list(APPEND CUGRAPH_CUDA_FLAGS -Xcompiler=${OpenMP_CXX_FLAGS})
endif()


################################################################################
# - find blas ------------------------------------------------------------------

if(NOT DEFINED BLAS_LIBRARIES)
find_package( BLAS REQUIRED )
else()
message(STATUS "Manually setting BLAS to ${BLAS_LIBRARIES}")
endif()

################################################################################
# - find CPM based dependencies -----------------------------------------------
###################################################################################################
# - find CPM based dependencies ------------------------------------------------------------------

rapids_cpm_init()

include(cmake/thirdparty/get_thrust.cmake)
include(cmake/thirdparty/get_faiss.cmake)
include(cmake/thirdparty/get_nccl.cmake)
include(cmake/thirdparty/get_rmm.cmake)

###
# Linking to the `raft::raft` target implicitly links cugraph targets to the
# following public header-only raft dependencies:
# * RMM
# * Thrust
# * libcu++
# * GTest/GMock
# * cuCollections
#
# The CMakeLists.txt for each of these projects are properly configured
# to generate a build and install export-set, so reimplementing finding or
# fetching those targets in cuGraph is redundant (at best), and potentially
# error-prone if something about those targets change and our implementation
# lags behind.
###
include(cmake/thirdparty/get_raft.cmake)

include(cmake/thirdparty/get_cuco.cmake)
include(cmake/thirdparty/get_nccl.cmake)
include(cmake/thirdparty/get_cuhornet.cmake)

if(BUILD_TESTS)
Expand Down Expand Up @@ -273,7 +275,6 @@ target_include_directories(cugraph
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty"
"${CMAKE_CURRENT_SOURCE_DIR}/src"
"${NCCL_INCLUDE_DIRS}"
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
Expand All @@ -283,17 +284,9 @@ target_include_directories(cugraph
# - link libraries -------------------------------------------------------------
target_link_libraries(cugraph
PUBLIC
rmm::rmm
cugraph::Thrust
raft::raft
PRIVATE
cuco::cuco
CUDA::cublas
CUDA::curand
CUDA::cusolver
CUDA::cusparse
cugraph::cuHornet
FAISS::FAISS
NCCL::NCCL
)

Expand Down Expand Up @@ -393,7 +386,6 @@ target_include_directories(cugraph_c
# - C-API link libraries -------------------------------------------------------
target_link_libraries(cugraph_c
PUBLIC
FAISS::FAISS
CUDA::cublas
CUDA::curand
CUDA::cusolver
Expand Down Expand Up @@ -446,17 +438,11 @@ cuGraph library is a collection of GPU accelerated graph algorithms that process

]=])

set(code_string
[=[
thrust_create_target(cugraph::Thrust FROM_OPTIONS)
]=])

rapids_export(INSTALL cugraph
rapids_export(INSTALL cugraph
EXPORT_SET cugraph-exports
GLOBAL_TARGETS cugraph cugraph_c
NAMESPACE cugraph::
DOCUMENTATION doc_string
FINAL_CODE_BLOCK code_string
)

################################################################################
Expand All @@ -466,7 +452,6 @@ rapids_export(BUILD cugraph
GLOBAL_TARGETS cugraph cugraph_c
NAMESPACE cugraph::
DOCUMENTATION doc_string
FINAL_CODE_BLOCK code_string
)

################################################################################
Expand Down
35 changes: 0 additions & 35 deletions cpp/cmake/thirdparty/get_cuco.cmake

This file was deleted.

53 changes: 0 additions & 53 deletions cpp/cmake/thirdparty/get_faiss.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion cpp/cmake/thirdparty/get_gtest.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2021, NVIDIA CORPORATION.
# Copyright (c) 2021-2022, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit bae28f7

Please sign in to comment.