Fix tf.svd() Fail to Run on GPU: Run it on CPU – TensorFlow Tutorial

By | May 28, 2020

TensorFlow tf.svd() function is not a good one, We have found two main problems on it:

1.Run slowly

Fix TensorFLow tf.svd() Run Slowly: A Beginner Guide

2.NaN Value

Solve tf.svd NaN bug with np.linalg.svd

We also find it can not be run on gpy. In this tutorial, we will introduce you how to fix this error.

Run tf.svd() on GPU

We use gpu to speed up tensorflow, however, we get this error.

tensorflow fail to run svd on gpu

Which means we can not run tensorflow tf.svd() function on gpu.

How to fix this error?

We should run tf.svd() on cpu, not gpu.

We can fix this error by this code.

with tf.device('/cpu:0'):
    s, u, v = tf.svd(inputs)

This code will make tf.svd() is running on our first cpu.

Leave a Reply