我想按照 this topic 中的说明设置 gpu 限制.
但我的代码是这样的:
deep_grap = tf.Graph()
with deep_grap.as_default():
### graph definition here
### graph definition here
with tf.Session(graph=deep_grap) as sess:
tf.initialize_all_variables().run()
### more computations here
在这种情况下,如何在我的代码中设置配置?
我没有直接的
sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))
线在这里。谢谢!
最佳答案
您可以通过 session 配置,一个 tf.ConfigProto
在 tf.Session()
with
中的初始化程序陈述:
deep_graph = tf.Graph()
with deep_graph.as_default():
### graph definition here
### graph definition here
config = tf.ConfigProto(gpu_options=...)
with tf.Session(graph=deep_graph, config=config) as sess:
tf.initialize_all_variables().run()
### more computations here
关于python - 如何实现tensorflow session 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41028919/