Cuda NVCC赢得';在/usr/lib/x86_64-linux-gnu中找不到库-为什么?

Cuda NVCC赢得';在/usr/lib/x86_64-linux-gnu中找不到库-为什么?,cuda,linker-errors,Cuda,Linker Errors,考虑以下CUDA程序,在名为foo.cu的文件中: #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 vo

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

#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();
}
只有当我用
-L/usr/lib/x86_64-linux-gnu
明确地添加库的文件夹时,它才愿意构建我的程序

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

注:

  • 我正在使用DevuanGNU/Linux3.0
  • CUDA 10.1作为分发包安装
  • 带有GeForce 1050 Ti卡的x86_64机器

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

在Devuan 3.0上,该文件中有一行内容是:

LIBRARIES   =+ $(_SPACE_) -L/usr/lib/x86_64-linux-gnu/stubs
这就是默认情况下您的NVCC所关注的地方

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

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

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

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

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

    Devuan不是CUDA开发支持的发行版。在Ubuntu(例如)上,使用,我不需要添加此处指示的
    -L
    开关,就可以让它工作。@RobertCrovella:仍然-nvlink搜索的路径是什么?是否有一个环境变量我可以设置?即使我可以回答这样的问题,我认为这样做是不明智的。它可以告诉未来的读者,这可能是一件安全或明智的事情。我不认为是这样。我的建议是转向受支持的开发环境。
    LIBRARIES   =+ $(_SPACE_) -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu/stubs