首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >编译hello.cpp。标志- C++ FAISS GPU

编译hello.cpp。标志- C++ FAISS GPU
EN

Stack Overflow用户
提问于 2022-02-07 15:24:31
回答 2查看 314关注 0票数 0

我想使用FAISS C++ GPU外部在另一个回购。因此,我创建了一个hello.cpp并试图编译它,而没有进入faiss目录。在faiss目录中,编译对我来说似乎很好。

  • hello.cpp (C++ Faiss GPU):
代码语言:javascript
复制
#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

输出:

代码语言:javascript
复制
/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命令来完成这个任务吗?什么是命令?

EN

回答 2

Stack Overflow用户

发布于 2022-08-18 08:49:33

您应该首先安装OpenBLAS或MKL。安装

票数 0
EN

Stack Overflow用户

发布于 2022-11-03 01:21:01

根据你的日志:

代码语言:javascript
复制
/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/local中安装了faiss,它使用mkl作为blas库进行编译。所以你需要安装mkl来使用它。如你所说:

在faiss目录中,编译对我来说似乎很好。

您的mkl库似乎已经在您的构建源代码树中了,如果您已经在faiss构建目录中找到它们,您可以尝试找到它们。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71021035

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档