对cusolverDn的未定义引用

时间:2015-03-26 17:05:07

标签: cuda cusolver

我正在尝试运行cuda 7.0中提供的cuSolver库。我有一个使用cuSolver库的问题,它必须非常简单才能解决,但在这里我要求一些帮助。

我已经查看了很多相关的例子,我特别从JackOLantern选择了这个例子:

Parallel implementation for multiple SVDs using CUDA

我刚把它缩减为kernel_0.cu:

#include "cuda_runtime.h"
#include "device_launch_parameters.h"

#include<iostream>
#include<iomanip>
#include<stdlib.h>
#include<stdio.h>
#include<assert.h> 
#include<math.h>

#include <cusolverDn.h>
#include <cuda_runtime_api.h>

#include "Utilities.cuh"

/********/
/* MAIN */
/********/
int main(){

// --- gesvd only supports Nrows >= Ncols
// --- column major memory ordering

// --- cuSOLVE input/output parameters/arrays
int *devInfo;           gpuErrchk(cudaMalloc(&devInfo,          sizeof(int)));

// --- CUDA solver initialization
cusolverDnHandle_t solver_handle;
cusolverDnCreate(&solver_handle);

cusolverDnDestroy(solver_handle);

return 0;

}

我使用相同的Utilities.cuh和Utilities.cu作为JackOlantern。我将其编译为(显式):

/usr/local/cuda-7.0/bin/nvcc kernel_0.cu Utilities.cu

我得到的是:

Utilities.cu(27): warning: conversion from a string literal to "char *" is deprecated

Utilities.cu(27): warning: conversion from a string literal to "char *" is deprecated

/tmp/tmpxft_00007e1d_00000000-22_kernel_0.o: In function `main':
tmpxft_00007e1d_00000000-4_kernel_0.cudafe1.cpp:(.text+0x3d): undefined     reference to `cusolverDnCreate'
tmpxft_00007e1d_00000000-4_kernel_0.cudafe1.cpp:(.text+0x49): undefined   reference to `cusolverDnDestroy'
collect2: error: ld returned 1 exit status

如果我注释掉cusolverDnCreate和cusolverDnDestroy,它编译得很好,所以显然很好地包含了库。

我错过了什么简单和基本的观点?我四处寻找,但我无法修复它。谢谢。

1 个答案:

答案 0 :(得分:3)

  

我错过了什么简单和基本的观点?

你必须链接cusolver库:

/usr/local/cuda-7.0/bin/nvcc kernel_0.cu Utilities.cu -lcusolver
相关问题