是否有任何快速命令或脚本来检查安装的CUDA版本?

我在安装目录下找到了4.0的手册,但我不确定它是否是实际安装的版本。


当前回答

打开终端并运行以下命令:

cd /usr/local/cuda/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery

您可以获得CUDA驱动程序版本、CUDA运行时版本的信息,以及GPU的详细信息。我的终端输出的图像示例如下。

您可以在此处找到图像。

其他回答

安装CUDA后,可以通过以下方式检查版本:nvcc-V

我已经安装了5.0和5.5

Cuda编译工具5.5版V5.5,0

此命令适用于Windows和Ubuntu。

使用CUDA运行时API C++包装器编程(注意:我是作者):

auto v1 = cuda::version::maximum_supported_by_driver();
auto v2 = cuda::version::runtime();

这为您提供了一个cuda::version_t结构,您可以对其进行比较,也可以打印/流式传输,例如:

if (v2 < cuda::version_t{ 8, 0 } ) {
    std::cerr << "CUDA version " << v2 << " is insufficient." std::endl;
}

使用tensorflow:

import tensorflow as tf
from tensorflow.python.platform import build_info as build
print(f"tensorflow version: {tf.__version__}")
print(f"Cuda Version: {build.build_info['cuda_version']}")
print(f"Cudnn version: {build.build_info['cudnn_version']}")

tensorflow版本:2.4.0

Cuda版本:11.0

Cudnn版本:8

你可能会发现CUDA-Z很有用,这里是他们网站上的一句话:

“这个程序诞生于另一个Z-实用程序的模仿,例如CPU-Z和GPU-Z。CUDA-Z显示了CUDA支持的GPU和GPGPU的一些基本信息。它与nVIDIA Geforce、Quadro和Tesla卡以及ION芯片组一起工作。”

http://cuda-z.sourceforge.net/

在支持选项卡上,有源代码的URL:http://sourceforge.net/p/cuda-z/code/并且下载实际上不是安装程序,而是可执行文件本身(没有安装,所以这是“快速”的)。

此实用程序提供了大量信息,如果您需要了解它是如何派生的,可以查看源代码。您可以搜索与此类似的其他实用程序。

如果您安装了PyTorch,只需在IDE中运行以下代码:

import torch

print(torch.version.cuda)