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

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


当前回答

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

其他回答

在Ubuntu上:

Try

$cat/usr/local/cuda/version.txt或$cat/usr/local/cuda-8.0/version.txt

有时文件夹名为“Cuda版本”。

如果以上都不起作用,请尝试转到$/usr/local/找到Cuda文件夹的正确名称。

输出应类似于:CUDA版本8.0.61

如果您在linux上运行:

dpkg -l | grep cuda

您可以使用

nvcc -V

或者你可以使用

nvcc --version

或者您可以检查CUDA使用的位置

whereis cuda 

然后做

cat location/of/cuda/you/got/from/above/command

在以下时间之后找到我的:

whereis cuda

at

cuda:/usr/lib/cuda/usr/include/cuda.h

with

nvcc --version

CUDA版本9.1.85

如果您已安装CUDA SDK,则可以运行“deviceQuery”查看CUDA的版本