undefined reference to cusolverDn

北城余情 提交于 2021-02-19 08:15:06

问题


I am trying to run the cuSolver library available in cuda 7.0. I have an issue with using the cuSolver library that must be very simple to fix, but here I am asking for some help.

I have looked at quite a few examples posted around and I chose in particular this one from JackOLantern:

Parallel implementation for multiple SVDs using CUDA

I have just reduced it to a 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;

}

I use the same Utilities.cuh and Utilities.cu as JackOlantern. I compile it as (to be explicit):

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

And what I get is:

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

If I comment out the cusolverDnCreate and cusolverDnDestroy, it compiles fine, so the library is apparently well included.

What simple and basic point am I missing? I have searched around, but I could not fix it. Thanks there.


回答1:


What simple and basic point am I missing?

You have to link against the cusolver library:

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


来源:https://stackoverflow.com/questions/29284631/undefined-reference-to-cusolverdn

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!