我正在尝试运行cuda 7.0中可用的cuSolver库。我在使用cuSolver库时遇到了一个问题,这个问题一定很容易解决,但在这里我寻求一些帮助。
我看了很多发布的例子,我特别选择了JackOLantern的这个:
使用CUDA 并行实现多个SVD
我刚刚把它简化为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;
}
我使用与JackOlinternan相同的Utilities.cuh和Utilities.cu。我把它编译为(明确地说):
/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和cusolverDenDestroy,它编译得很好,所以库显然包含得很好。
我缺少什么简单而基本的要点?我到处找了找,但找不到。谢谢。
我缺少什么简单而基本的要点?
你必须链接到cusolver库:
/usr/local/cuda-7.0/bin/nvcc kernel_0.cu Utilities.cu -lcusolver