0

我想将 FAISS C++ GPU 代码写入 FasterTransformer C++ GPU。

  1. https://github.com/facebookresearch/faiss
  2. https://github.com/NVIDIA/FasterTransformer

我在 sample/cpp/CMakeLists.txt 中这样做了:

add_subdirectory(<FaissPath>/faiss faiss)
add_subdirectory(<FaissPath>/swig swigfaiss)
target_link_libraries(decoding_beamsearch_sample PUBLIC -lcublas -lcublasLt -lcudart -lgflags faiss swigfaiss decoder decoding)
link_directories(/usr/local/lib/)

在 fasttransformer/decoding_beamsearch.h 中,我写道:

#include "fastertransformer/utils/common.h"
#include "fastertransformer/utils/functions.h"
#include "fastertransformer/utils/allocator.h"
#include "fastertransformer/open_decoder.h"
#include "fastertransformer/cuda/cuda_kernels.h"
#include "fastertransformer/utils/arguments.h"
#include <cuda_runtime.h>
   
#include <sys/time.h>

#include <faiss/gpu/GpuIndexIVFPQ.h>
#include <faiss/gpu/StandardGpuResources.h>
#include <faiss/gpu/GpuCloner.h>
#include <faiss/utils/random.h> 
#include <faiss/gpu/utils/DeviceUtils.h>
#include <faiss/gpu/utils/Timer.h> 

#include <faiss/gpu/GpuAutoTune.h>
#include <faiss/index_io.h>

我在其中一个函数中写了以下内容:

faiss::gpu::StandardGpuResources res;

这是我的 FasterTransformer 的 CMake 命令:

cmake -B build . -DSM=70 -DCMAKE_BUILD_TYPE=Release -DBUILD_PYT=ON -DFAISS_ENABLE_GPU=ON -DCUDAToolkit_ROOT=/usr/local/cuda/ -DCMAKE_CUDA_ARCHITECTURES="70" -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DFAISS_OPT_LEVEL=avx2 -DBUILD_TESTING=ON

我看到这个警告

CMake Warning at fastertransformer/th_op/CMakeLists.txt:41 (add_library):
Cannot generate a safe runtime search path for target pyt_fastertransformer
because there is a cycle in the constraint graph:
dir 0 is [/usr/local/cuda/lib64] dir 3 must precede it due to runtime
library [libnvToolsExt.so.1] dir 1 is [/usr/local/mpi/lib] dir 2 is
[/opt/conda/lib/python3.8/site-packages/torch/lib] dir 3 is
[/opt/conda/lib] dir 0 must precede it due to runtime library
[libcufft.so.10] Some of these libraries may not be found correctly.
-- Generating done
-- Build files have been written to: FasterTransformer/build

当 make -j 时,代码构建良好。当我运行时,我看到这个错误

OSError:/FasterTransformer/FasterTransformer/build/lib/libpyt_fastertransformer.so:未定义符号:_ZN5faiss3gpu20StandardGpuResourcesD1Ev

如果您对从 Faiss 到 FT 的链接警告/错误有所了解,请分享。

4

0 回答 0