我遇到了tensorflow-gpu 1.6.0的一些问题。
我正在Coursera上完成“贝叶斯方法在机器学习中”的最终作业。
https://www.coursera.org/learn/bayesian-methods-in-machine-learning
当我用tensorflow-gpu(pip install tensorflow-gpu
)在GPU上运行代码时,Python会崩溃,但如果我使用标准的tensorflow(pip install tensorflow
)在CPU上运行相同的代码,则代码可以快速运行而没有错误或崩溃。显然,在安装标准版本和GPU版本之前,我已经卸载了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')
补充信息:
- Python版本为3.6.4
- TensorFlow版本为1.6.0
- TensorFlow-gpu版本为1.6.0
- CUDA 9.0的cuDNN版本为7.1.1
- CUDA 9.0带有补丁1和2
- GPU为1080ti,驱动程序版本为391.01
你可以在wetransfer上找到Python笔记本和权重文件:https://wetransfer.com/downloads/59b9011823d38c204b5ef5a2b58f5e8e20180311201808/32c900