简体   繁体   English

缺少符号:cuDevicePrimaryCtxRelease 与 cuDevicePrimaryCtxRelease_v2

[英]Missing symbol: cuDevicePrimaryCtxRelease vs cuDevicePrimaryCtxRelease_v2

I'm trying to build the following program:我正在尝试构建以下程序:

#include <iostream>
#include <cuda.h>

int main() {
    const char* str;

    auto status = cuInit(0);
    cuGetErrorString(status, &str);
    std::cout << "status = " << str << std::endl;

    int device_id = 0;
    CUcontext primary_context_id;
    status = cuDevicePrimaryCtxRetain(&primary_context_id, device_id);
    cuGetErrorString(status, &str);
    std::cout << "status = " << str << std::endl;

    status = cuDevicePrimaryCtxRelease(device_id);
    cuGetErrorString(status, &str);
    std::cout << "status = " << str << std::endl;
}

Compilation always goes fine;编译总是很顺利; but, with CUDA 10.2, linking works, while with CUDA 11.2, I get:但是,使用 CUDA 10.2,链接工作,而使用 CUDA 11.2,我得到:

/usr/bin/ld: a.o: in function `main':
a.cpp:(.text+0xcc): undefined reference to `cuDevicePrimaryCtxRelease_v2'
collect2: error: ld returned 1 exit status

Why is this happening and how can I fix it?为什么会发生这种情况,我该如何解决?

Note: I'm using Devuan Beowulf with driver version 440.82 (have not installed a new driver for CUDA 11.2).注意:我正在使用带有驱动程序版本 440.82 的 Devuan Beowulf(尚未为 CUDA 11.2 安装新驱动程序)。

Well, I think I have an idea of why this happens.好吧,我想我知道为什么会发生这种情况。

This is about how cuDevicePrimaryCtxRelease() is defined.这是关于如何定义cuDevicePrimaryCtxRelease()的。 Let's run:让我们运行:

grep PrimaryCtxRelease /usr/local/cuda/include/cuda.h | grep -v "^ "

In CUDA 10.2, we get:在 CUDA 10.2 中,我们得到:

CUresult CUDAAPI cuDevicePrimaryCtxRelease(CUdevice dev);

while in CUDA 11.2, we get:而在 CUDA 11.2 中,我们得到:

#define cuDevicePrimaryCtxRelease           cuDevicePrimaryCtxRelease_v2
CUresult CUDAAPI cuDevicePrimaryCtxRelease(CUdevice dev);

That is, the API name has changed, but the header file leaves an alias to the new name.也就是说,API 名称已更改,但 header 文件为新名称留下了别名。 (And that's a confusing piece of code, I would say.) (我会说,这是一段令人困惑的代码。)

Now, let's peer into the object files I get in the two different versions of CUDA, using objdump -t | c++filt | grep cu现在,让我们看看我在两个不同版本的 CUDA 中得到的 object 文件,使用objdump -t | c++filt | grep cu objdump -t | c++filt | grep cu objdump -t | c++filt | grep cu . objdump -t | c++filt | grep cu With CUDA 10.2, it's:使用 CUDA 10.2,它是:

0000000000000000         *UND*  0000000000000000 cuInit
0000000000000000         *UND*  0000000000000000 cuGetErrorString
0000000000000000         *UND*  0000000000000000 cuDevicePrimaryCtxRetain
0000000000000000         *UND*  0000000000000000 cuDevicePrimaryCtxRelease

while with CUDA 11.2, it's:而使用 CUDA 11.2,它是:

0000000000000000         *UND*  0000000000000000 cuInit
0000000000000000         *UND*  0000000000000000 cuGetErrorString
0000000000000000         *UND*  0000000000000000 cuDevicePrimaryCtxRetain
0000000000000000         *UND*  0000000000000000 cuDevicePrimaryCtxRelease_v2

(note the _v2 ). (注意_v2 )。

so it's probably the case that the installed driver only contains the non- _v2 symbol, hence the undefined symbol.所以可能是安装的驱动程序只包含非_v2符号,因此是未定义的符号。

What I would still appreciate help with is how to work around this issue other than by updating the driver.我仍然希望得到帮助的是如何解决这个问题,而不是更新驱动程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SSL v2未定义符号,Manjaro和Ubuntu - SSL v2 undefined symbol, Manjaro and Ubuntu 列出每行带有 -v 符号的文件名 - List file names with -v symbol on each line ldd -r -v 如何将版本符号添加到文件中? - ldd -r -v How do I add version symbol to file? GDB调试缺少特定调用堆栈的符号表的核心转储 - GDB debugging a coredump with missing symbol tables for a specific call stack 构建内核模块并解决缺少的符号定义[已解决:过时的源代码] - building kernel module and resolve missing symbol definitions [solved: outdated source] 未定义的符号引用 '<symbol> '...添加符号时出错:命令行中缺少 DSO(使用 CMake)</symbol> - Undefined Reference to Symbol '<Symbol>' ... Error Adding Symbols: DSO Missing From Command Line (With CMake) 对符号/ ..libdl.so.2的未定义引用:添加符号时出错:命令行缺少DSO - undefined reference to symbol / ..libdl.so.2: error adding symbols: DSO missing from command line Linux 和共享库,链接 vs dlopen - 符号可见性 - Linux and shared libraries, linking vs dlopen - symbol visibility Linux内核v2.6 +中的pthread与kthread - pthread vs. kthread in Linux kernel v2.6+ 指向符号的ABI稳定性与常规符号查找 - ABI stability on pointers to symbols vs regular symbol lookup
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM