【问题标题】:Trouble working with CUSPARSE使用 CUPARSE 遇到问题
【发布时间】:2012-03-29 07:36:57
【问题描述】:

当我想编译我的程序(使用 Cusparse)时,出现了以下几行:

tmp/tmpxft_00001048_00000000-13_matvec.o:在函数main': tmpxft_00001048_00000000-1_matvec.cudafe1.cpp:(.text+0x6d5): undefined reference tocusparseCreate'

同样的结果不仅适用于 cusparseCreate,而且适用于 cusparseCreateMatDescr、cusparseSetMatType、cusparseSetMatIndexBase、cusparseXcoo2csr、cusparseDsctr、 cusparseDcsrmv_v2、cusparseDestroyMatDescr 和 cusparseDestroy。什么意思?

【问题讨论】:

  • 你是怎么编译的?看起来您没有链接到 cusparse 库。如何链接库的答案取决于操作系统。
  • 如何解决 windows visual studio 2010 的同样问题?
  • @Terminal,下面是解决 Visual Studio 问题的方法:stackoverflow.com/questions/13570285/…

标签: cuda


【解决方案1】:

您需要链接到 cuSPARSE 库。由于您使用的是 Linux,将 -lcusparse 添加到您的 nvcc 命令行就足够了。

请注意,如果系统在执行时找不到链接的库,您可能还需要将 CUDA 库路径添加到您的 LD_LIBRARY_PATH 环境变量中。

【讨论】:

  • 我是否遗漏了什么,或者您是否有办法从他提出的问题中推断出 OP 正在使用 Linux?
  • 错误信息是典型的 Linux 错误信息,Windows 会说类似“未解析的外部符号”。我不知道 Mac 说什么,所以他可能正在使用 Mac,但在那种情况下,分辨率是一样的。对于 Windows,按照以下说明添加 cusparse.lib 和 cudart.lib:stackoverflow.com/a/2047892/214473 (VS2005/2008) 或 stackoverflow.com/a/7285235/214473 (VS2010)。
  • 我一直在我们的系统中看到这些错误消息!可笑的是我没有注意到这一点。感谢您的澄清。
  • 是的,我确实在使用 Linux (Ububtu)。谢谢你的建议。我添加了 -lcusparse 并编译了它。但现在,我面临另一个问题。问题是我想使用 cuComplex 变量将矩阵与向量 (cusparseCcsrmv) 相乘。但是尽管程序编译,它不会返回结果。向量应该是什么样的对象?函数形式为:
  • cusparseCcsrmv(cusparseHandle_t handle, cusparseOperation_t transA, int m, int n, int nnz, const cuComplex *alpha, const cusparseMatDescr_t descrA, const cuComplex *csrValA, const int *csrRowPtrA, const int *csrColIndA, const cuComplex *x, const cuComplex *beta, cuComplex *y)
猜你喜欢
  • 2011-07-29
  • 2013-05-19
  • 2023-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-21
  • 2021-11-08
  • 2014-01-08
相关资源
最近更新 更多