卸载tensorflow
pip uninstall tensorflow
conda uninstall tensorflow
安装tensorflow-gpu
conda install tensorflow-gpu
测试,结果非0即可
import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
若不行,则重建conda环境
# 创建环境
conda create -n 新环境名称
# 进入环境
conda activate 新环境名称
# 安装环境,把tensorflow-gpu与python版本写在一起,可让conda同时考虑版本兼容问题
conda install -c anaconda -c conda-forge tensorflow-gpu=1.15 python=3.7