我将R与Keras和tensorflow 2.0一起在GPU上使用。
将第二台显示器连接到我的GPU后,在深度学习脚本中收到此错误:
我得出的结论是,GPU的内存不足,似乎是这样的解决方案:
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
config = tf.ConfigProto()
config.gpu_options.allow_growth = True # dynamically grow the memory used on the GPU
config.log_device_placement = True # to log device placement (on which device the operation ran)
# (nothing gets printed in Jupyter,only if you run it standalone)
sess = tf.Session(config=config)
set_session(sess) # set this TensorFlow session as the default session for Keras
根据此帖子: https://github.com/tensorflow/tensorflow/issues/7072#issuecomment-422488354
尽管R不接受此代码。 它说
来自Tensorflow的意外令牌。
tf.ConfigProto()错误:找不到函数“ tf.ConfigProto”
如果我从这篇文章中了解正确的话,似乎tensorflow 2.0不接受此代码: https://github.com/tensorflow/tensorflow/issues/33504
有人知道我如何使用Keras库和Tensorflow 2.0从我的R脚本中最大限度地利用GPU吗?
谢谢!