安装keras+tf

1.查看keras和tf的对应版本

https://docs.floydhub.com/guides/environments/

2.keras如何使用GPU?

https://blog.csdn.net/qq_33182424/article/details/106080243 

检查GPU:

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

 

 

 

 检查是否可利用GPU:

from keras import backend as K
K.tensorflow_backend._get_available_gpus()

 

 

 

 

 

3.判断tf是否可以使用GPU?

https://blog.csdn.net/xiaozisheng2008_/article/details/80558914

import os
import tensorflow as tf
import numpy as np

hello=tf.constant('hhh')
sess=tf.Session()
print (sess.run(hello))

 

 

 

出现上面这样的就说明可以用了。

然后安装对应版本的keras,之后再使用keras,有如下代码

import os
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"

os.environ["CUDA_VISIBLE_DEVICES"]="0"

 

就可以使用gpu了。

4.安装keras-contrib

https://blog.csdn.net/qq_31456593/article/details/89388107

pip install git+https://www.github.com/keras-team/keras-contrib.git

 

posted @ 2020-09-17 00:32  lypbendlf  阅读(249)  评论(0编辑  收藏  举报