为什么我的nvcc拒绝查看/ usr / lib / x86_64-linux-gnu?

问题描述 投票:-1回答:1

在名为foo.cu的文件中考虑以下CUDA程序:

#include <cooperative_groups.h>
#include <stdio.h>

__global__ void my_kernel() {
    auto g = cooperative_groups::this_grid();
    g.sync();
}

int main(int, char **) {
    cudaLaunchCooperativeKernel( (const void*) my_kernel, 2, 2, nullptr, 0, nullptr);
    cudaDeviceSynchronize();
}

此程序需要用-rdc=true编译(请参见this question);并且需要与libcudadevrt明确链接。好的,没问题...还是??>

$ nvcc -rdc=true -o foo  -gencode arch=compute_61,code=sm_61 foo.cu  -lcudadevrt
nvlink error   : Undefined reference to 'cudaCGGetIntrinsicHandle' in '/tmp/tmpxft_000036ec_00000000-10_foo.o'
nvlink error   : Undefined reference to 'cudaCGSynchronizeGrid' in '/tmp/tmpxft_000036ec_00000000-10_foo.o'

仅当我用-L/usr/lib/x86_64-linux-gnu明确添加库的文件夹时,才愿意构建我的程序。

这很奇怪,因为我系统上的所有CUDA库都在该文件夹中。为什么NVCC / nvlink不在那里?

注意:

  • 我正在使用Devuan GNU / Linux 3.0。
  • CUDA 10.1已作为分发包安装。
  • 带有GeForce 1050 Ti卡的x86_64机器。

请在名为foo.cu的文件中考虑以下CUDA程序:#include #include __global__ void my_kernel(){auto g =合作组:: this_grid(); ...

cuda linker-errors nvlink
1个回答
0
投票

NVCC,或者也许是nvlink,在名为LIBRARIES的环境变量中查找路径。但是-在执行此操作之前,将执行shell脚本/etc/nvcc.profile(至少在Devuan上)。

在Devuan 3.0上,该文件的一行显示:

LIBRARIES   =+ $(_SPACE_) -L/usr/lib/x86_64-linux-gnu/stubs

因此,这是您的NVCC默认情况下的查找位置。

因此,您可以执行以下两项操作之一:

  1. 在NVCC外部设置环境变量,例如在您的~/.profile~/.bashrc文件中:

    export LIBRARIES=-L/usr/lib/x86_64-linux-gnu/stubs
    
  2. nvcc.profile行改为:

    LIBRARIES   =+ $(_SPACE_) -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu/stubs
    

并且NVCC将成功构建您的二进制文件。

© www.soinside.com 2019 - 2024. All rights reserved.