NVCC不会在/usr/lib/x86_64-linux-gnu中查找库-为什么? [英] NVCC won't look for libraries in /usr/lib/x86_64-linux-gnu - why?

查看:340
本文介绍了NVCC不会在/usr/lib/x86_64-linux-gnu中查找库-为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Consider the following CUDA program, in a file named 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();
}

该程序需要使用-rdc=true进行编译(请参见此问题);并且需要明确链接libcudadevrt.好的,没问题...是吗?

This program needs to be compiled with -rdc=true (see this question); and needs to be explicitly linked against libcudadevrt. Ok, no problem... or is it?

$ 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明确添加库的文件夹时,它才愿意构建我的程序.

Only if I explicitly add the library's folder with -L/usr/lib/x86_64-linux-gnu, is it willing to build my program.

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

This is strange, because all of the CUDA libraries on my system are in that folder. Why isn't NVCC/nvlink looking in there?

注意:

  • 我正在使用Devuan GNU/Linux 3.0.
  • CUDA 10.1已作为分发软件包安装.
  • 一台带有GeForce 1050 Ti卡的x86_64计算机.

推荐答案

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

NVCC, or perhaps nvlink, looks for paths in an environment variable named LIBRARIES. But - before doing so, the shell script /etc/nvcc.profile is executed (at least, it is on Devuan).

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

On Devuan 3.0, that file has a line saying:

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

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

so that's where your NVCC looks to by default.

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

You can therefore do one of two things:

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

export LIBRARIES=-L/usr/lib/x86_64-linux-gnu/stubs

  • nvcc.profile行更改为:

  • Change that nvcc.profile line to say:

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

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

    and NVCC will successfully build your binary.

    这篇关于NVCC不会在/usr/lib/x86_64-linux-gnu中查找库-为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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