How to build the latest version of Gunrock (a popular GPU Graph analytic library) on Redhat/Centos based systems
Prerequisites:
- cmake 3.10+
- GCC 4.8+
Although building gunrock is easy on Ubuntu 18.04, it is not easy for other OSs.
In most of the RedHat rpms, cmake is not the latest. Sometimes we do not have root/admin rights to install. In such scenarios, below steps to build cmake/gunrock.
Build/Download cmake - 4 steps
1. Download cmake*.tar.gz from
https://cmake.org/download/
download either src or binary
2. Extract
3) // do either a or b
a. if src, cd to cmake directory and do make
b. if binary, do nothing
4. To verify
./cmake-3.14.7/bin/cmake --version
displays as below
cmake version 3.14.7
CMake suite maintained and supported by Kitware (kitware.com/cmake).
Build Gunrock - 6 steps
1.) Set and export CUDA Bin path to your cuda. Mine is 9.1. Note a non-default location!
CUDA_BIN_PATH=/usr/local/cuda-9.1
export CUDA_BIN_PATH
2)
git clone --recursive https://github.com/gunrock/gunrock/
cd gunrock
3)
In gunrock folder, edit
CMakeLists.txt
at the following lines as per your GPU card. Ours is Nvidia P100. So, I
have changed that corresponding flag from OFF to ON. Find your card name using
nvidia-smi command.
if (CUDA_VERSION VERSION_EQUAL "8.0" OR CUDA_VERSION VERSION_GREATER "8.0")
option(GUNROCK_GENCODE_SM60
"ON to generate code for Compute Capability 6.0 devices (e.g. Tesla P100)"
ON)
Note: This Step may not be needed due to this
#665 pull request
4)
mkdir build && cd build
~/install/cmake-3.14.7/bin/cmake ..
we are using the cmake which we downloaded/build previously.
Note: Always make sure your build folder is empty before cmake. If you end up with
some errors due to cmake; make sure to delete all files and folders from
build before performing cmake again.
Upon success. Should display the following:
..
-- Project Added: bc
-- Project Added: bfs
-- Project Added: color
-- Project Added: geo
-- Project Added: hits
-- Project Added: knn
-- Project Added: louvain
-- Project Added: pr
-- Project Added: pr_nibble
-- Project Added: proj
-- Project Added: rw
-- Project Added: sage
-- Project Added: sm
-- Project Added: ss
-- Project Added: sssp
-- Project Added: tc
-- Project Added: vn
-- Configuring done
-- Generating done
-- Build files have been written to: /home/rajesh/tmp/gunrock/build2
5)
make
Takes up to an hour or so as. If no error, then that's all. If you need only a specific algorithm (say SSSP), then read
A1 below.
6) To test, cd to bin inside build dir
./sssp market ../dataset/small/test_mst.mtx
...sample output..
Distance Validity: PASS
First 40 distances of the GPU result:
[0:0 1:2 2:4 3:19 4:14 5:2147483647 6:2147483647 7:2147483647 8:2147483647 ]
First 40 distances of the reference CPU result.
[0:0 1:2 2:4 3:19 4:14 5:2147483647 6:2147483647 7:2147483647 8:2147483647 ]
[sssp] finished.
avg. elapsed: 0.551939 ms
iterations: 4
min. elapsed: 0.551939 ms
max. elapsed: 0.551939 ms
rate: 0.016306 MiEdges/s
src: 0
nodes_visited: 5
edges_visited: 9
load time: 7.15208 ms
preprocess time: 943.713000 ms
postprocess time: 0.494003 ms
total time: 945.014000 ms
YAY :-)
Appendix
A1) You could build only a specific algorithm by setting an appropriate flag during your cmake as said here in
advanced compilation.
e.g. Suppose if I want SSSP alone then
/cmake-3.14.7/bin/cmake -DGUNROCK_BUILD_APPLICATIONS=OFF -DGUNROCK_APP_SSSP=ON ..
//This step builds SSSP alone when you do a make.
Errors in the past that lead to the above working steps:
E1) CMake 3.10 or higher is required. You are running version 2.8.12.2
E2) CMake Error at /home/rajesh/install/cmake-3.16.1-Linux-x86_64/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find CUDA: Found unsuitable version "8.0", but required is at
least "9.0" (found /usr)
Call Stack (most recent call first):
/home/rajesh/install/cmake-3.16.1-Linux-x86_64/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:391 (_FPHSA_FAILURE_MESSAGE)
/home/rajesh/install/cmake-3.16.1-Linux-x86_64/share/cmake-3.16/Modules/FindCUDA.cmake:1104 (find_package_handle_standard_args)
CMakeLists.txt:41 (FIND_PACKAGE)
END- gunrock-cmd.txt