使用CUDA驱动程序API VS2012时无法解析的外部符号 [英] Unresolved External Symbols when using CUDA Driver API VS2012

查看:243
本文介绍了使用CUDA驱动程序API VS2012时无法解析的外部符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用CUDA驱动程序API来加载.ptx文件和包含以下代码的函数:

I've been trying to use the CUDA driver API to load a .ptx file and a function from it with this code:

CUdevice device;
cuDeviceGet(&device,0);
CUcontext ctx;
cuCtxCreate(&ctx,0,device);
CUmodule mod;
cuModuleLoad(&mod,"kernel.ptx");
CUfunction func;
cuModuleGetFunction(&func,mod,"kernel");
CUdeviceptr ints;
cuMemAlloc(&ints,(sizeof(int)*30));

但是在编译时出现以下错误:

However at compile time I get these errors:

    1>kernel.cu.obj : error LNK2019: unresolved external symbol _cuDeviceGet@8 referenced in function _main
    1>kernel.cu.obj : error LNK2019: unresolved external symbol _cuCtxCreate_v2@12 referenced in function _main
    1>kernel.cu.obj : error LNK2019: unresolved external symbol _cuModuleLoad@8 referenced in function _main
    1>kernel.cu.obj : error LNK2019: unresolved external symbol _cuModuleGetFunction@12 referenced in function _main
    1>kernel.cu.obj : error LNK2019: unresolved external symbol _cuMemAlloc_v2@8 referenced in function _main
    1>kernel.cu.obj : error LNK2019: unresolved external symbol _cuMemcpyHtoD_v2@12 referenced in function _main
    1>kernel.cu.obj : error LNK2019: unresolved external symbol _cuMemcpyDtoH_v2@12 referenced in function _main
    1>kernel.cu.obj : error LNK2019: unresolved external symbol _cuLaunchKernel@44 referenced in function _main

中引用的符号_cuLaunchKernel @ 44我在VS2012中创建了一个新的CUDA 5.5项目并键入了直接进入生成的.cu文件,但是在编译时出现了这些错误。如果我进行的测试不使用驱动程序api,则不会出现任何错误!

I created a new CUDA 5.5 project in VS2012 and typed this directly into the generated .cu file however at compile time I got these errors. If I do a test that doesn't use the driver api I don't get any errors!

推荐答案

当您不链接 cuda.lib 时,会发生这些错误。

Those errors occur when you are not linking against cuda.lib.

这篇关于使用CUDA驱动程序API VS2012时无法解析的外部符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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