1

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.

Community
  • 1
  • 1
SRH
  • 23
  • 1
  • 6
  • They are warnings, not errors. You are compiling under Linux, while I'm compiling under Windows. In the `Utilities.cu`, change the `char *file` entry of the `gpuErrchk` function to `const char *file`. This should solve the issue. Be aware that the `gpuErrchk` function has been posted by @talonmies at [What is the canonical way to check for errors using the CUDA runtime API?](http://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api). – Vitality Mar 26 '15 at 17:40
  • Thanks JackOLantern! – SRH Mar 26 '15 at 21:27

1 Answers1

5

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
Robert Crovella
  • 143,785
  • 11
  • 213
  • 257
  • Thanks very much Robert (and for so many other helpful answers). That fixed it. – SRH Mar 26 '15 at 21:23