在"/tmp/tmpxft_0000120b_0000000-10_my_program"中对"cublasCreate_v2"的未定义引用 [英] Undefined reference to `cublasCreate_v2’ in ‘/tmp/tmpxft_0000120b_0000000-10_my_program”

查看:265
本文介绍了在"/tmp/tmpxft_0000120b_0000000-10_my_program"中对"cublasCreate_v2"的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用NVIDIA Tesla P100图形卡(Ubuntu版本16.04)上的CUDA 9.0工具包编译代码,并且代码中使用了CUBLAS库.为了进行编译,我使用以下命令来编译"my_program.cu"

I have tried to compile a code using CUDA 9.0 toolkit on NVIDIA Tesla P100 graphic card (Ubuntu version 16.04) and CUBLAS library is used in the code. For compilation, I have used the following command to compile "my_program.cu"

nvcc -std=c++11 -L/usr/local/cuda-9.0/lib64 my_program.cu -o mu_program.o -lcublas

但是,我遇到了以下错误:

But, I have got the following error:

nvlink错误:'/tmp/tmpxft_0000120b_0000000-10_my_program'

由于我已经在编译命令中链接了库路径,为什么仍然出现错误.请帮助我解决此错误.

As I have already linked the library path in the compilation command, why do I still get the error. Please help me to solve this error.

推荐答案

似乎很明显,您正在尝试在设备代码中使用 CUBLAS库.这与普通主机用法不同,并且需要特殊的编译/链接步骤.您需要:

It seems fairly evident that you are trying to use the CUBLAS library in device code. This is different than ordinary host usage and requires special compilation/linking steps. You need to:

  1. 针对正确的设备架构进行编译(必须为cc3.5或更高版本)
  2. 使用可重定位设备代码链接
  3. cublas 设备库中的
  4. 链接(除了cublas主机库之外)
  5. CUDA设备运行时库中的链接
  6. 在CUDA 10.0之前使用CUDA工具包

在编译命令行中添加以下内容可以使您到达那里:

The following additions to your compile command line should get you there:

nvcc -std=c++11 my_program.cu -o my_program.o -lcublas -arch=sm_60 -rdc=true -lcublas_device -lcudadevrt

以上内容假设您实际上使用的是CUDA 9.0的正确安装.CUBLAS设备库已弃用,现在已从较新的CUDA工具包中删除(请参阅

The above assumes you are actually using a proper install of CUDA 9.0. The CUBLAS device library was deprecated and is now removed from newer CUDA toolkits (see here).

这篇关于在"/tmp/tmpxft_0000120b_0000000-10_my_program"中对"cublasCreate_v2"的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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