安装tensorflow
同时用pip安装了tensorflow和tensorflow-gpu,可能会默认使用tensorflow,为了防止之前的版本对现在的干扰,全部卸掉
然后需要 pip uninstall keras tensorflow tensorflow-gpu
之后使用cinda安装:conda install tensorflow-gpu keras
使用conda安装的好处是可以帮你搭建好环境,而不用自己费力装CUDA,CUDNN等
测试GPU是否可用
tensorflow
import tensorflow as tf
print(tf.test.is_gpu_available())
tf.config.list_physical_devices('GPU')
pytorch
import torch
print(torch.cuda.is_available())
输出True代表可用