对 cusolverDn 的未定义引用
undefined reference to cusolverDn
我正在尝试 运行 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;
}
我使用与 JackOlantern 相同的 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 和 cusolverDnDestroy,它编译得很好,所以这个库显然很好地包含在内。
我缺少什么简单和基本的要点?我四处搜寻,但无法修复。谢谢。
What simple and basic point am I missing?
您必须 link 针对 cusolver 库:
/usr/local/cuda-7.0/bin/nvcc kernel_0.cu Utilities.cu -lcusolver
我正在尝试 运行 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;
}
我使用与 JackOlantern 相同的 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 和 cusolverDnDestroy,它编译得很好,所以这个库显然很好地包含在内。
我缺少什么简单和基本的要点?我四处搜寻,但无法修复。谢谢。
What simple and basic point am I missing?
您必须 link 针对 cusolver 库:
/usr/local/cuda-7.0/bin/nvcc kernel_0.cu Utilities.cu -lcusolver