Skip to content

Commit be5756d

Browse files
committed
release 0.1
1 parent 5a3a765 commit be5756d

39 files changed

+5463
-11
lines changed

.clang-format

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
DerivePointerAlignment: false
5+
PointerAlignment: Left

.gitignore

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
3rdparty/
2+
build/
3+
build_docker/
4+
build_local/
5+
.vscode
6+
data/**
7+
8+
include/ggnn/alternatives
9+
10+
### CMake ###
11+
CMakeLists.txt.user
12+
CMakeCache.txt
13+
CMakeFiles
14+
CMakeScripts
15+
Testing
16+
Makefile
17+
cmake_install.cmake
18+
install_manifest.txt
19+
compile_commands.json
20+
CTestTestfile.cmake
21+
_deps
22+
23+
### CMake Patch ###
24+
# External projects
25+
*-prefix/
26+
27+
### C++ ###
28+
# Prerequisites
29+
*.d
30+
31+
# Compiled Object files
32+
*.slo
33+
*.lo
34+
*.o
35+
*.obj
36+
37+
# Precompiled Headers
38+
*.gch
39+
*.pch
40+
41+
# Compiled Dynamic libraries
42+
*.so
43+
*.dylib
44+
*.dll
45+
46+
# Fortran module files
47+
*.mod
48+
*.smod
49+
50+
# Compiled Static libraries
51+
*.lai
52+
*.la
53+
*.a
54+
*.lib
55+
56+
# Executables
57+
*.exe
58+
*.out
59+
*.app

.gitmodules

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[submodule "3rdparty/pybind11"]
2+
path = 3rdparty/pybind11
3+
url = https://github.com/pybind/pybind11.git
4+
[submodule "3rdparty/cub"]
5+
path = 3rdparty/cub
6+
url = https://github.com/NVlabs/cub.git
7+
[submodule "3rdparty/eigen-git-mirror"]
8+
path = 3rdparty/eigen-git-mirror
9+
url = https://github.com/eigenteam/eigen-git-mirror.git
10+
[submodule "3rdparty/glog"]
11+
path = 3rdparty/glog
12+
url = https://github.com/google/glog.git

3rdparty/cub

Submodule cub added at c3cceac

3rdparty/eigen-git-mirror

Submodule eigen-git-mirror added at 36b9596

3rdparty/glog

Submodule glog added at 0a2e593

3rdparty/pybind11

Submodule pybind11 added at b886369

CMakeLists.txt

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
CMAKE_MINIMUM_REQUIRED( VERSION 3.3.0 )
2+
3+
project (GGNN)
4+
set(CMAKE_CXX_STANDARD 14)
5+
6+
7+
find_package(CUDA REQUIRED)
8+
9+
set(CUDA_ARCH_LIST Auto)
10+
cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS ${CUDA_ARCH_LIST})
11+
list(APPEND CUDA_NVCC_FLAGS ${CUDA_ARCH_FLAGS})
12+
13+
set(EIGEN_INCLUDE_PATH "3rdparty/eigen-git-mirror")
14+
set(CUB_INCLUDE_PATH "3rdparty/cub")
15+
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std=c++14 -Xptxas=-v --expt-relaxed-constexpr --default-stream per-thread" )
16+
17+
add_subdirectory("3rdparty/pybind11")
18+
set(GFLAGS_NAMESPACE "google")
19+
add_subdirectory("3rdparty/glog")
20+
21+
message("CUDA_ARCH_LIST: ${CUDA_ARCH_LIST}")
22+
message("CUDA_NVCC_FLAGS: ${CUDA_NVCC_FLAGS}")
23+
24+
cuda_add_executable(demo src/demo.cu)
25+
target_include_directories(demo
26+
PRIVATE
27+
${CUDA_NVCC_FLAGS}
28+
${EIGEN_INCLUDE_PATH}
29+
${CUB_INCLUDE_PATH}
30+
${CMAKE_CURRENT_SOURCE_DIR}/include
31+
)
32+
target_link_libraries(demo ${CUDA_curand_LIBRARY} glog::glog)
33+

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Computergraphics (University of Tübingen)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+61-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,69 @@
11
# GGNN: Graph-based GPU Nearest Neighbor Search
2-
Fabian Groh, Lukas Ruppert, Patrick Wieschollek, Hendrik P.A. Lensch
2+
*Fabian Groh, Lukas Ruppert, Patrick Wieschollek, Hendrik P.A. Lensch
33

4-
Abstract
5-
-------------------
4+
Approximate nearest neighbor (ANN) search in high dimensions is an integral part of several computer vision systems and gains importance in deep learning with explicit memory representations. Since PQT and FAISS started to leverage the massive parallelism offered by GPUs, GPU-based implementations are a crucial resource for today’s state-of-the-art ANN methods. While most of these methods allow for faster queries, less emphasis is devoted to accelerate the construction of the underlying index structures. In this paper, we propose a novel search structure based on nearest neighbor graphs and information propagation on graphs. Our method is designed to take advantage of GPU architectures to accelerate the hierarchical building of the index structure and for performing the query. Empirical evaluation shows that GGNN significantly surpasses the state-of-the-art GPU- and CPU-based systems in terms of build-time, accuracy and search speed.
65

7-
Approximate nearest neighbor (ANN) search in high dimensions is an integral part of several computer vision systems and gains importance in deep learning with explicit memory representations. Since PQT and FAISS started to leverage the massive parallelism offered by GPUs GPU-based implementations are a crucial resource for today’s state-of-the-art ANN methods. While most of these methods allow for faster queries, less emphasis is devoted to accelerate the construction of the underlying index structures. In this paper, we propose a novel search structure based on nearest neighbor graphs and information propagation on graphs. Our method is designed to take advantage of GPU architectures to accelerate the hierarchical building of the index structure and for performing the query. Empirical evaluation shows that GGNN significantly surpasses the state-of-the-art GPU- and CPU based systems in terms of build-time, accuracy and search speed.
6+
---
87

9-
Code
10-
-------------------
8+
## How to run the code?
119

12-
Code will be available upon publication.
13-
If you have any questions please feel free to contact us.
10+
```bash
11+
# Get the repository and dependencies
12+
git clone --recursive https://github.com/cgtuebingen/ggnn.git
13+
cd ggnn
1414

15+
# get the SIFT1M data
16+
cd data
17+
./get_sift1m
18+
cd ..
1519

16-
More Resources
17-
-------------------
20+
# Build the demo
21+
mkdir build_local
22+
cd build_local
23+
cmake ..
24+
make
1825

19-
- [Arxiv Pre-Print](https://arxiv.org/abs/1912.01059)
26+
# Usage of demo:
27+
# ./demo <base.xvecs> <query.xvecs> <gt.ivecs> <tau_build> <refinement_iterations> [<GPU id>] [<graph_cache.ggnn>]
28+
./demo ../data/sift/sift_base.fvecs ../data/sift/sift_query.fvecs ../data/sift/sift_groundtruth.ivecs 0.5 2 0 --v 0
29+
```
30+
31+
32+
### Native build
33+
34+
Requirements:
35+
* CUDA (>10.2)
36+
* libgflags-dev (`sudo apt install libgflags-dev`)
37+
38+
39+
### Docker build
40+
An alternative to the native build is to use nvidia-docker. Follow instruction on https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#installing-docker-ce
41+
42+
Prepare the docker image by
43+
44+
```bash
45+
cd docker
46+
make
47+
cd ../
48+
```
49+
50+
Make sure you can run
51+
52+
```bash
53+
sudo docker run --gpus all cgtuebingen/ggnn:v1 nvidia-smi
54+
```
55+
56+
Now build the code via
57+
58+
```bash
59+
user@host $ sudo docker run --rm -it --user "$(id -u):$(id -g)" -v ${PWD}:/ggnn:rw --gpus all cgtuebingen/ggnn:v1 bash
60+
user@container $ ./build.sh
61+
62+
cd build_docker
63+
make
64+
./demo ../data/sift/sift_base.fvecs ../data/sift/sift_query.fvecs ../data/sift/sift_groundtruth.ivecs 0.5 2 0 --v 0
65+
```
66+
67+
## More Resources
68+
69+
- [Arxiv Pre-Print](https://arxiv.org/abs/1912.01059)

build.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cd /code
2+
rm -rf build_docker
3+
mkdir -p build_docker
4+
cd build_docker
5+
cmake ..
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <cuda_runtime.h>
2+
#include <cstdio>
3+
int main()
4+
{
5+
int count = 0;
6+
if (cudaSuccess != cudaGetDeviceCount(&count)) return -1;
7+
if (count == 0) return -1;
8+
for (int device = 0; device < count; ++device)
9+
{
10+
cudaDeviceProp prop;
11+
if (cudaSuccess == cudaGetDeviceProperties(&prop, device))
12+
std::printf("%d.%d ", prop.major, prop.minor);
13+
}
14+
return 0;
15+
}

data/get_sift1m.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
wget ftp://ftp.irisa.fr/local/texmex/corpus/sift.tar.gz
4+
tar -xzf sift.tar.gz

docker/Dockerfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM nvidia/cuda:10.2-cudnn7-devel
2+
3+
RUN APT_INSTALL="apt-get install -y --no-install-recommends" && \
4+
rm -rf /var/lib/apt/lists/* \
5+
/etc/apt/sources.list.d/cuda.list \
6+
/etc/apt/sources.list.d/nvidia-ml.list && \
7+
apt-get update && \
8+
DEBIAN_FRONTEND=noninteractive $APT_INSTALL \
9+
build-essential \
10+
ca-certificates \
11+
cmake \
12+
python3.5 \
13+
python-dev \
14+
python3-dev \
15+
libgflags-dev \
16+
git
17+
18+
WORKDIR /ggnn

docker/makefile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.PHONY: run
2+
3+
build:
4+
sudo docker build . -t cgtuebingen/ggnn:v1

0 commit comments

Comments
 (0)