从源代码构建#
以下说明适用于希望从源代码构建 wholegraph 的用户。这些说明已在支持的 Linux、CUDA 和 Python 发行版上进行测试 - 有关支持环境的列表,请参阅 RAPIDS 入门指南。其他操作系统可能兼容,但目前尚未测试。
wholegraph 包包含 C/C++ CUDA 部分和 Python 部分。需要安装这两个库,cuGraph 才能正常运行。C/C++ CUDA 库是 libwholegraph
,Python 库是 pylibwholegraph
。
先决条件#
编译器:
gcc
版本 11.0+nvcc
版本 11.0+cmake
版本 3.26.4+
CUDA:
CUDA 11.8+
Volta 架构或更高版本
您可以从 https://developer.nvidia.com/cuda-downloads 获取 CUDA。
其他软件包:
ninja
nccl
cython
setuputils3
scikit-learn
scikit-build-core
nanobind>=0.2.0
构建 wholegraph#
要从源代码安装 wholegraph,请确保满足依赖项。
克隆仓库并配置 Conda 环境#
GIT 克隆仓库的某个版本
# Set the location to wholegraph in an environment variable WHOLEGRAPH_HOME
export WHOLEGRAPH_HOME=$(pwd)/wholegraph
# Download the wholegraph repo - if you have a forked version, use that path here instead
git clone https://github.com/rapidsai/wholegraph.git $WHOLEGRAPH_HOME
cd $WHOLEGRAPH_HOME
创建 conda 开发环境
# create the conda environment (assuming in base `wholegraph` directory)
# for CUDA 11.x
conda env create --name wholegraph_dev --file conda/environments/all_cuda-118_arch-x86_64.yaml
# activate the environment
conda activate wholegraph_dev
# to deactivate an environment
conda deactivate
随着开发包含/更改依赖项,环境可以更新。为此,运行
# Where XXX is the CUDA version
conda env update --name wholegraph_dev --file conda/environments/all_cuda-XXX_arch-x86_64.yaml
conda activate wholegraph_dev
使用 build.sh
脚本构建和安装#
使用 build.sh
脚本可以轻松编译和安装 wholegraph。要构建和安装,只需执行
$ cd $WHOLEGRAPH_HOME
$ ./build.sh clean
$ ./build.sh libwholegraph
$ ./build.sh pylibwholegraph
构建脚本上还有其他几个选项可供高级用户使用。build.sh
选项
build.sh [<target> ...] [<flag> ...]
where <target> is:
clean - remove all existing build artifacts and configuration (start over).
uninstall - uninstall libwholegraph and pylibwholegraph from a prior build/install (see also -n)
libwholegraph - build the libwholegraph C++ library.
pylibwholegraph - build the pylibwholegraph Python package.
tests - build the C++ (OPG) tests.
benchmarks - build benchmarks.
docs - build the docs
and <flag> is:
-v - verbose build mode
-g - build for debug
-n - no install step
--allgpuarch - build for all supported GPU architectures
--cmake-args=\\\"<args>\\\" - add arbitrary CMake arguments to any cmake call
--compile-cmd - only output compile commands (invoke CMake without build)
--clean - clean an individual target (note: to do a complete rebuild, use the clean target described above)
-h | --h[elp] - print this text
default action (no args) is to build and install 'libwholegraph' then 'pylibwholegraph' targets
examples:
$ ./build.sh clean # remove prior build artifacts (start over)
$ ./build.sh
# make parallelism options can also be defined: Example build jobs using 4 threads (make -j4)
$ PARALLEL_LEVEL=4 ./build.sh libwholegraph
Note that the libraries will be installed to the location set in `$PREFIX` if set (i.e. `export PREFIX=/install/path`), otherwise to `$CONDA_PREFIX`.
独立构建每个部分#
构建和安装 C++/CUDA libwholegraph
库#
CMake 依赖于 nvcc
可执行文件位于您的路径中或定义在 $CUDACXX
中。
本项目使用 cmake 构建 C/C++ 库。要配置 cmake,运行
# Set the location to wholegraph in an environment variable WHOLEGRAPH_HOME
export WHOLEGRAPH_HOME=$(pwd)/wholegraph
cd $WHOLEGRAPH_HOME
cd cpp # enter cpp directory
mkdir build # create build directory
cd build # enter the build directory
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
# now build the code
make -j # "-j" starts multiple threads
make install # install the libraries
默认安装位置分别是 $CMAKE_INSTALL_PREFIX/lib
和 $CMAKE_INSTALL_PREFIX/include/wholegraph
。
构建和安装 Python 包#
将 Python 包构建并安装到您的 Python 路径
cd $WHOLEGRAPH_HOME
cd python
cd pylibwholegraph
python setup.py build_ext --inplace
python setup.py install # install pylibwholegraph
运行测试#
使用数据集运行 C++ 或 Python 测试
带数据集的 Python 测试
cd $WHOLEGRAPH_HOME cd python pytest
C++ 独立测试
从构建目录
# Run the tests cd $WHOLEGRAPH_HOME cd cpp/build gtests/PARALLEL_UTILS_TESTS # this is an executable file
注意:此 conda 安装仅适用于 Linux 以及 Python 版本 3.10、3.11 和 3.12。
创建文档#
Python API 文档可以从 ./docs/wholegraph 目录生成。或者通过使用“./build.sh docs”生成。
归属#
部分内容改编自 https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md