我对tensorflow-gpu 1.6.0有点麻烦。
我正在考瑟拉的“机器学习的方法”课上做最后的作业。
https://www.coursera.org/learn/bayesian-methods-in-machine-learning
当我使用tensorflow-gpu (pip install tensorflow-gpu)在GPU上运行代码时,python会崩溃,但是如果我使用标准的tensorflow (pip isntall tensorflow)在CPU上运行相同的代码,则代码运行得很快,不会出现错误或崩溃。很明显,在我安装标准版本之前,我对gpu版本进行了分离,反之亦然。
关于python崩溃,调试器显示了以下消息:
Unhandled exception at 0x00007FFDAB4DB79E (ucrtbase.dll) in python.exe这是起始代码:
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import clear_output
import tensorflow as tf
import GPy
import GPyOpt
import keras
from keras.layers import Input, Dense, Lambda, InputLayer, concatenate, Activation, Flatten, Reshape
from keras.layers.normalization import BatchNormalization
from keras.layers.convolutional import Conv2D, Deconv2D
from keras.losses import MSE
from keras.models import Model, Sequential
from keras import backend as K
from keras import metrics
from keras.datasets import mnist
from keras.utils import np_utils
from tensorflow.python.framework import ops
from tensorflow.python.framework import dtypes
import utils
import os
%matplotlib inline
sess = tf.InteractiveSession()
K.set_session(sess)
latent_size = 8
vae, encoder, decoder = utils.create_vae(batch_size=128, latent=latent_size)
sess.run(tf.global_variables_initializer())
vae.load_weights('CelebA_VAE_small_8.h5')
K.set_learning_phase(False)
latent_placeholder = tf.placeholder(tf.float32, (1, latent_size))
decode = decoder(latent_placeholder)这段代码在GPU上执行时会导致python崩溃,而不是在CPU:上执行。
plt.figure(figsize=(10, 10))
for i in range(25):
plt.subplot(5, 5, i+1)
image = sess.run(decode, feed_dict={latent_placeholder: np.random.normal([0]*latent_size,[1]*latent_size)[:, np.newaxis].T})[0]### YOUR CODE HERE
plt.imshow(np.clip(image, 0, 1))
plt.axis('off')附加信息:
您可以在wetransfer: https://wetransfer.com/downloads/59b9011823d38c204b5ef5a2b58f5e8e20180311201808/32c900上找到python笔记本和权重
发布于 2018-03-12 14:23:45
我发现了问题。cuDNN 7.1.1还不适用于tensorflow-gpu。我将cuDNN降级为7.0.5,现在代码按预期的方式工作。
如果你有像我这样的问题,你必须降低cuDNN的评级!
https://stackoverflow.com/questions/49224425
复制相似问题