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

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


当前回答

您可以使用

nvcc -V

或者你可以使用

nvcc --version

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

whereis cuda 

然后做

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

其他回答

除了上面提到的那些,CUDA安装路径(如果在安装过程中没有更改)通常包含版本号

执行哪个nvcc应该提供路径,这将为您提供版本

PS:这是一种快速而肮脏的方式,上面的答案更优雅,并将通过相当大的努力产生正确的版本

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

如果nvcc--版本不适合您,请使用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

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

我已经安装了5.0和5.5

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

此命令适用于Windows和Ubuntu。