在 Linux 上找到 CUDA 安装

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4812539/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 02:38:57  来源:igfitidea点击:

Locate CUDA installation on Linux

linuxpathinstallcuda

提问by Narcolessico

What's the best way? Here are my solutions:

最好的方法是什么?以下是我的解决方案:

echo $PATH | sed "s/:/\n/g" | grep "cuda/bin" | sed "s/\/bin//g" |  head -n 1
which nvcc | sed "s/\/bin\/nvcc//"
which nvcc | head -c -10

They are all PATH-based. One could locate libraries instead. It would be more robust if there are no CUDA paths in PATH.

它们都是基于 PATH 的。人们可以找到图书馆。如果 PATH 中没有 CUDA 路径会更健壮。

I'm using this in a Makefile.

我在 Makefile 中使用它。

回答by Francois G

How does something based onldconfig -p | grep libcudasound ? Considering an appropriate ldconfig setupis explicitly advised at the end of the installation of the CUDA toolkit, it should do the trick without path nicely, I think.

怎么做基于ldconfig -p | grep libcuda声音的东西?考虑到在 CUDA 工具包安装结束时明确建议进行适当的 ldconfig 设置,我认为它应该可以很好地完成没有路径的技巧。