反正还有在GPU上运行Tensorflow代码吗?

问题描述 投票:0回答:1

[这是我的代码,我想将GPU用于我的代码。当前它正在CPU上运行。

    elf.graph = tf.Graph()
    with self.graph.as_default():
        self.face_graph = tf.GraphDef()
        fid=tf.gfile.GFile(self.facenet_model, 'rb')
        serialized_graph = fid.read()
        self.face_graph.ParseFromString(serialized_graph)
        tf.import_graph_def(self.face_graph, name='')
        self.facenet_sess = tf.Session(graph=self.graph)
        self.images_placeholder = self.graph.get_tensor_by_name("input:0")
        self.embeddings = self.graph.get_tensor_by_name("embeddings:0")
python tensorflow gpu-programming
1个回答
0
投票

包装在里面

with tf.device('/GPU:0'):
    ....
© www.soinside.com 2019 - 2024. All rights reserved.