我TensorFlow在Windows 8和Python 3.5上使用.我改变了这个简短的例子来看看,如果GPU支持(Titan X)工作.不幸的是运行时用(tf.device("/gpu:0")和没有(tf.device("/cpu:0"))使用GPU是相同的.Windows CPU监视显示,在两种情况下,CPU负载在计算期间约为100%.
这是代码示例:
import numpy as np
import tensorflow as tf
import datetime
#num of multiplications to perform
n = 100
# Create random large matrix
matrix_size = 1e3
A = np.random.rand(matrix_size, matrix_size).astype('float32')
B = np.random.rand(matrix_size, matrix_size).astype('float32')
# Creates a graph to store results
c1 = []
# Define matrix power
def matpow(M, n):
if n < 1: #Abstract cases where n < 1
return M
else: …Run Code Online (Sandbox Code Playgroud)