lengstrom / fast-style-transfer

TensorFlow CNN for fast style transfer ⚡🖥🎨🖼
10.92k stars 2.6k forks source link

Codes only Training on CPU #165

Open JangminSon opened 6 years ago

JangminSon commented 6 years ago

I have question about codes In src/optimize.py,

with tf.Graph().as_default(), tf.device('/cpu:0'), tf.Session() as sess:

I Thought it is meant to training on the CPU (I mean using cpu). And if I run this code, It only use GPU Memory and doesn't use its processing power. and If I trying to change cpu into gpu, It occurs error below.

tensorflow.python.framework.errors_imp.InvalidArgumentError: Cannot assign a device for operation ‘save/SaveV2’: Could not satisfy explicit device specification ‘/device:GPU:0’ because no supported kernel for GPU devices is available

So I erased the 'tf.device ' part and It worked fine. Am I misunderstood something?

I'm using TF version - 1.4 Python 2.7.12 CUDA 8.0 with cudnn

I hope it would help someone with this error like me.

JEF1056 commented 6 years ago

That line of code line 31 is for preprocessing data in optimize.py. It does not affect training, it only loads files into memory.

line 42 with tf.Graph().as_default(), tf.Session() as sess: is where training occurs, and it should use your GPU (if you have one) by default.