Cuda cusolver无法在Visual studio 2013中链接 [英] Cuda cusolver can't link in Visual studio 2013

查看:1536
本文介绍了Cuda cusolver无法在Visual studio 2013中链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过基本一切,我不能得到vs2013来编译和链接cusolver库。我已经尝试了所有的示例项目附带的cuda安装包,基本上所有的样品工作正常。虽然没有使用cusolver的样本。包含文件工作正常。链接器是错误的,所有其他的cuda东西链接就好了。我试着添加一行cusolver代码到一个完美的工作cuda示例,它打破。以下是代码片段:

  #includecuda_runtime.h
#includedevice_launch_parameters.h
#includecusolver_common.h
#includecusolverDn.h
#include< stdio.h>

cudaError_t addWithCuda(int * c,const int * a,const int * b,unsigned int size);

__global__ void addKernel(int * c,const int * a,const int * b)
{
int i = threadIdx.x;
c [i] = a [i] + b [i];
}

int main()
{
cusolverDnCreate(new cusolverDnHandle_t);

return 0;
}

构建输出是:


$ b b

  1> ------ Build started:项目:cudan,配置:Release x64 ------ 
1>编译CUDA源文件kernel.cu ...
1>
1> c:\Users\Gdizzle\documents\visual studio 2013\Projects\ the cudan \ the cudan>C:\Program Files \NVIDIA GPU Computing Toolkit \CUDA\v7.0\\ \\bin \\\
vcc.exe-gencode = arch = compute_20,code = \sm_20,compute_20 \--use-local-env --cl-version 2013 -ccbinC:\Program Files(x86 )\Microsoft Visual Studio 12.0 \VC\bin\x86_amd64-IC:\Program Files \ NVIDIA GPU计算工具包\CUDA \v7.0 \include-IC:\\ \\ Program Files \ NVIDIA GPU计算工具包\CUDA\v7.0\include--keep-dir x64 \Release -maxrregcount = 0 --machine 64 --compile -cudart static -DWIN32 -DWIN64 -DNDEBUG -D_CONSOLE -D_MBCS -Xcompiler/ EHsc / W3 / nologo / O2 / Zi / MD-o x64\Release\kernel.cu.objc:\Users\Gdizzle\documents\visual studio 2013 \Projects\ cudan \ cudan \kernel.cu
1> kernel.cu
1> kernel.cu.obj:error LNK2001:未解析的外部符号cusolverDnCreate
1> c:\users\gdizzle\documents\visual studio 2013\Projects\ cudan \x64 \Release\ the cudan.exe:fatal error LNK1120:1 unresolved externals

我试图在项目属性中添加目录 - > vc ++和链接器选项,这没有帮助。有任何想法吗?这很奇怪,这1库不工作。



(另外,如果你有任何其他的想法如何解决方程组的最小二乘使用gpu编程将有帮助)



编辑更新:不能通过在其他链接器选项(如cudaLinker)中添加额外的库或其他include目录来包含额外的.h文件或额外的库或vc ++目录

解决方案我刚刚在Windows 7 64位,Visual Studio 2013社区, CUDA 7。


  1. 首先打开vectorAdd cuda示例代码。请确保您可以正确构建此代码。 (它应该是一个x64项目。 CUDA 7不支持32位项目或Windows操作系统。)如果你无法正确构建,你的问题与cusolver无关。


  2. p>在vectorAdd.cu的顶部添加以下头文件:

      #include< cusolverDn.h> 


  3. 将以下两行添加到 / code>例程:

      cusolverDnHandle_t my_handle; 
    cusolverDnCreate(& my_handle);


  4. 转到项目... vectorAdd属性...链接器...输入.. 。其他依赖关系。在这个字段中,你应该已经找到了一些库,包括cudart_static.lib。单击此字段,然后单击右侧的下拉菜单箭头,然后单击<编辑...> 在库列表的底部在编辑窗口中,在其自己的行上添加 cusolver.lib


  5. 重新构建项目。 / p>



I have tried basically everything and I can't get vs2013 to compile and link against the cusolver library. I have tried all the sample projects that came with the cuda installation package and basically all of the samples work fine. Though there are no samples using cusolver. The include files work just fine. The linker is in error and all of the other cuda stuff links just fine. I tried adding one line of cusolver code to a perfectly working cuda sample and it breaks. Here is the code snippet:

#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "cusolver_common.h"
#include "cusolverDn.h"
#include <stdio.h>

cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size);

__global__ void addKernel(int *c, const int *a, const int *b)
{
    int i = threadIdx.x;
    c[i] = a[i] + b[i];
}

int main()
{
    cusolverDnCreate(new cusolverDnHandle_t);

    return 0;
}

The build output is:

1>------ Build started: Project: The cudan, Configuration: Release x64 ------
1>  Compiling CUDA source file kernel.cu...
1>  
1>  c:\Users\Gdizzle\documents\visual studio 2013\Projects\The cudan\The cudan>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --use-local-env --cl-version 2013 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64"  -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include"     --keep-dir x64\Release -maxrregcount=0  --machine 64 --compile -cudart static     -DWIN32 -DWIN64 -DNDEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /O2 /Zi  /MD  " -o x64\Release\kernel.cu.obj "c:\Users\Gdizzle\documents\visual studio 2013\Projects\The cudan\The cudan\kernel.cu" 
1>  kernel.cu
1>kernel.cu.obj : error LNK2001: unresolved external symbol cusolverDnCreate
1>c:\users\gdizzle\documents\visual studio 2013\Projects\The cudan\x64\Release\The cudan.exe : fatal error LNK1120: 1 unresolved externals

I've tried adding directories in project properties -> vc++ and in linker options and that didn't help. Any ideas? It's so weird that this 1 Library doesn't work.

(Also if you have any other ideas on how to solve a systems of equations with least squares using gpu programming that would be helpful)

EDIT UPDATE: You must not include extra .h files nor extra libs by adding additional libraries or additional include directories in other linker options like cudaLinker or vc++ directories

解决方案

I've just tested this on Windows 7 64-bit, Visual Studio 2013 Community, CUDA 7.

  1. start by opening the vectorAdd cuda sample code. Be sure you can build this code correctly. (It should be a x64 project. CUDA 7 does not support 32-bit projects or operating systems on windows.) If you can't build this correctly, your issue has nothing to do with cusolver

  2. Add the following header file at the top of vectorAdd.cu:

    #include <cusolverDn.h>
    

  3. Add the following two lines to the beginning of the main routine:

    cusolverDnHandle_t my_handle;
    cusolverDnCreate(&my_handle);
    

  4. Go to Project...vectorAdd Properties...Linker...Input...Additional Dependencies. In this field you should already find a number of libraries including cudart_static.lib. Click in this field, then click on the drop-down menu arrow on the right, then click on <Edit...> At the bottom of the list of libraries in the edit window, add cusolver.lib on its own line.

  5. Rebuild the project.

这篇关于Cuda cusolver无法在Visual studio 2013中链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆