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

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


当前回答

[编辑的答案。感谢所有更正的人]

如果你跑步

nvidia-smi

您应该在命令输出的右上角找到安装的驱动程序支持的CUDA版本最高CUDA版本。至少我发现CUDA版本10.0的输出。,

其他回答

我得到/usr/local-没有这样的文件或目录。尽管nvcc-V给出了

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Sun_Sep__4_22:14:01_CDT_2016
Cuda compilation tools, release 8.0, V8.0.44

使用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/并且下载实际上不是安装程序,而是可执行文件本身(没有安装,所以这是“快速”的)。

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

我们有三种方法来检查版本:在我的案例中,以下是输出:-方式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

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

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

import torch

print(torch.version.cuda)