tensorflow: tf.matrix_inverse() is slow compared to numpy.linalg.inv
Running this snippet
import numpy as np
import scipy as sp
from datetime import datetime
import tensorflow as tf
s = tf.Session()
dim = 3000
mat = tf.random_uniform((dim,dim))
s.run(tf.initialize_all_variables())
matinv = tf.matrix_inverse(mat)
st = datetime.now()
s.run(matinv)
print "time elapsed tensorflow:", datetime.now() - st
st = datetime.now()
x = np.random.rand(dim,dim)
sp.linalg.inv(x)
print "time elapsed scipy: ", datetime.now() - st
yields this output
I tensorflow/core/common_runtime/gpu/gpu_device.cc:643] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 750 Ti, pci bus id: 0000:01:00.0)
time elapsed tensorflow: 0:00:18.078232
time elapsed scipy: 0:00:01.613825
1.6 sec (Scipy) vs. ~18 sec (tensorflow), that’s a huge difference.
- Is this expected behavior?
- Why is TensorFlow so slow when inverting a matrix? I was hoping it leverages the GPU.
- Is there a way to improve the TensorFlow runtime duration?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 22 (6 by maintainers)
Commits related to this issue
- Implement MultinomialOp (#221) * [SYCL] Improve GatherOp (#219) * [Eigen] Version bump * [SYCL] Implements MultinomialOp — committed to codeplaysoftware/tensorflow by Rbiessy 6 years ago
- Emit empty lines after headers when generating op docs This makes the generated doc easier to read and it is also more friendly to certain markdown parsers like kramdown. Fixes #221 PiperOrigin-Rev... — committed to tensorflow/tensorflow by antiagainst 5 years ago
- Merge pull request #221 from ROCmSoftwarePlatform/develop-upstream-miopen-fusion-integration-prs "Add+Relu" and "AddN+ReluGrad" fusions (custom HIP kernel implementations). Merging this PR as previou... — committed to Cerebras/tensorflow by whchung 6 years ago
Hello! Any news on this regarding GPU implementation?