无法转换BatchDescriptor CUDNN_STATUS_BAD_PARAM

时间:2019-01-31 05:15:37

标签: python tensorflow keras deep-learning

我正在尝试创建一个多输入模型并在cifar集上对其进行测试, 但是我遇到了这个错误:

"2019-01-31 14:02:18.966015: F T:\src\github\tensorflow\tensorflow\stream_executor\cuda\cuda_dnn.cc:521] could not convert BatchDescriptor {count: 10 feature_map_count: 288 spatial: 0 0 value_min: 0.000000 value_max: 0.000000 layout: BatchDepthYX} to cudnn tensor descriptor: CUDNN_STATUS_BAD_PARAM"

我提到了前面的问题,但是我没有使用生成器,而是在cifar数据集上对其进行了测试。

tensorflow GPU crashes for 0 batch size CUDNN_STATUS_BAD_PARAM

这是我的代码:

#multiple outout models

##imports##
#--Keras imports--#

from keras.applications import resnet50, xception,inception_v3,inception_resnet_v2, densenet, nasnet, imagenet_utils
from keras.preprocessing import image
from keras.preprocessing.image import ImageDataGenerator
from keras.layers import Input, Dense
from keras import backend as K
from keras.models import Model, clone_model
from keras.layers import Dense, GlobalAveragePooling2D,Dropout, BatchNormalization, InputLayer
from keras import optimizers
from keras.callbacks import ModelCheckpoint,ProgbarLogger,LearningRateScheduler
from keras.utils import print_summary
from keras import __version__
from keras.layers.merge import concatenate
from keras.utils import plot_model
from keras.datasets import cifar10
from keras.utils import np_utils



#--python imports--#
import os
import numpy as np
import datetime
import h5py
import json
import time
import math
import random


#data


(X_train, y_train), (X_test, y_test) = cifar10.load_data()

X_train = X_train.astype('float32')
X_test = X_test.astype('float32')
X_train /= 255
X_test /= 255


Y_train = np_utils.to_categorical(y_train, 10)
Y_train =np.concatenate([Y_train,Y_train], -1)
Y_test = np_utils.to_categorical(y_test, 10)


print(X_train.shape)



def full_model_1():
    base_model, preprocess = xception.Xception(weights='imagenet', include_top=False), xception.preprocess_input
    base_model2, preprocess2 = inception_v3.InceptionV3(weights='imagenet', include_top=False), inception_v3.preprocess_input
    x = base_model.output
    x = GlobalAveragePooling2D()(x)
    x = Dense(1024, activation='relu')(x)
    x = Dense(10, activation='softmax')(x)
    y = base_model2.output
    y = GlobalAveragePooling2D()(y)
    y = Dense(1024, activation='relu')(y)
    y = Dense(10, activation='softmax')(y)

    final = concatenate([x, y])

    model = Model(inputs= [base_model.input,base_model2.input] ,outputs=final)
    return model, preprocess, preprocess2




model,_,_ = full_model_1()

r_optimizer = optimizers.SGD(lr=0.0001, momentum = .8)
model.compile(optimizer= r_optimizer,
              loss='categorical_crossentropy',
              metrics = ['accuracy'])

x =model.fit([X_train, X_train], Y_train, 
              epochs = 1, batch_size=10, callbacks=None)


print("finished")

0 个答案:

没有答案