【发布时间】:2022-11-03 09:21:01
【问题描述】:
我想在另一个仓库中外部使用 FAISS C++ GPU。因此,我创建了一个 hello.cpp 并尝试在不进入 faiss 目录的情况下对其进行编译。在 faiss 目录中,编译对我来说似乎很好。
- hello.cpp(C++ Faiss GPU):
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <random>
#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 <fstream>
#include <faiss/gpu/utils/DeviceUtils.h>
#include <faiss/gpu/utils/Timer.h>
#include <string>
#include <iostream>
#include <faiss/gpu/GpuAutoTune.h>
#include <faiss/index_io.h>
using namespace std;
double elapsed() {
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec + tv.tv_usec * 1e-6;
}
int main() {
double t0 = elapsed();
printf("[%.3f s] Hello World! :))\n",
elapsed() - t0);
faiss::gpu::StandardGpuResources res; // Without this line, nvcc works.
return 0;
}
命令:
/usr/local/cuda/bin/nvcc /home/hossamamer/hello.cpp -lcublas -lfaiss -o myCublasApp
输出:
/usr/bin/ld: warning: libmkl_intel_lp64.so, needed by /usr/local/lib/libfaiss.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libmkl_gnu_thread.so, needed by /usr/local/lib/libfaiss.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libmkl_core.so, needed by /usr/local/lib/libfaiss.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: /usr/local/lib/libfaiss.so: undefined reference to `dgemm_'
/usr/bin/ld: /usr/local/lib/libfaiss.so: undefined reference to `dgetri_'
/usr/bin/ld: /usr/local/lib/libfaiss.so: undefined reference to `dgetrf_'
/usr/bin/ld: /usr/local/lib/libfaiss.so: undefined reference to `ssyrk_'
/usr/bin/ld: /usr/local/lib/libfaiss.so: undefined reference to `sgetrf_'
/usr/bin/ld: /usr/local/lib/libfaiss.so: undefined reference to `sgelsd_'
/usr/bin/ld: /usr/local/lib/libfaiss.so: undefined reference to `sgemm_'
/usr/bin/ld: /usr/local/lib/libfaiss.so: undefined reference to `dgesvd_'
/usr/bin/ld: /usr/local/lib/libfaiss.so: undefined reference to `dsyev_'
/usr/bin/ld: /usr/local/lib/libfaiss.so: undefined reference to `sgeqrf_'
/usr/bin/ld: /usr/local/lib/libfaiss.so: undefined reference to `sorgqr_'
/usr/bin/ld: /usr/local/lib/libfaiss.so: undefined reference to `sgesvd_'
/usr/bin/ld: /usr/local/lib/libfaiss.so: undefined reference to `sgetri_'
collect2: error: ld returned 1 exit status
有什么帮助吗?我也可以使用 make 命令执行此操作吗?命令是什么?
【问题讨论】:
-
faiss 显然希望你链接到英特尔 MKL。首先,如果您还没有安装 MKL,则需要安装。然后您需要在命令行中添加一些 mkl 库。请参阅here“基本要求是:...... BLAS 实现(我们强烈建议使用英特尔 MKL 以获得最佳性能)。”
-
谢谢。安装英特尔 MKL 使其工作。知道我是否需要在另一个仓库外部使用 FAISS C++ GPU 并使用 cmake 进行编译。我需要为 cmake 做哪些更改?
标签: c++ linux gpu intel-mkl faiss