关于tensorflow无法使用gpu

python3.6 无法使用tensorflow gpu

环境名称 test1

在控制台里进入环境

conda activate test1

使用python

python

查看gpu能否使用

print(tf.config.list_physical_devices('GPU'))

cuda版本查看 nvcc -V

10.2.89

判断是否使用了gpu:

推荐的方法是检查TensorFlow是否使用GPU如下:

tf.config.list_physical_devices('GPU') 

输出:【这个很重要】

[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

以下内容还将返回您的GPU设备的名称。

import tensorflow as tf
tf.test.gpu_device_name()

如果non-GPU安装了该软件包的版本,则该函数还将返回False。使用tf.test.is_built_with_cuda来验证是否TensorFlow是建立在CUDA的支持。

*注意*tf.test.is_gpu_available已弃用。请参考这里

警告:此功能已被弃用。它将在将来的版本中删除。更新说明:改用tf.config.list_physical_devices('GPU')。

我最后终于搞出来了
用的就是CUDA_VISIBLE_DEVICES网上的方法

posted @ 2021-06-25 22:59  KinoLogic  阅读(2260)  评论(0)    收藏  举报