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

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


当前回答

我们有三种方法来检查版本:在我的案例中,以下是输出:-方式1:-

cat /usr/local/cuda/version.txt

输出:-

CUDA Version 10.1.243

途径2:-

nvcc --version

输出:-

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85

途径3:-

/usr/local/cuda/bin/nvcc --version

输出:-

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243

途径4:-

nvidia-smi
NVIDIA-SMI 450.36.06    Driver Version: 450.36.06    CUDA Version: 11.0

输出不相同。不知道为什么会这样。

其他回答

安装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;
}

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

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

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

您可以在此处找到图像。

首先你应该找到Cuda的安装位置。

如果是像这里这样的默认安装,位置应该是:

对于ubuntu:

/usr/local/cuda

在此文件夹中,您应该有一个文件

版本.txt

使用任何文本编辑器打开此文件或运行:

cat version.txt

从文件夹

OR

 cat /usr/local/cuda/version.txt 

使用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