Tensorflow.python.framework.errors_impl.UnknownError

Ask Questions Forum: ask Machine Learning Questions to our readersCategory: Deep LearningTensorflow.python.framework.errors_impl.UnknownError
Adesoji Alu asked 1 month ago

tensorflow.python.framework.errors_impl.UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
[[node sequential/vgg16/block1_conv1/Relu (defined at \Downloads\Compressed\ML-in-production-main\model.py:31) ]] [Op:__inference_predict_function_4191]

Function call stack:
predict_function

my code below

from flask import Flask, render_template, request
# if you encounter dependency issues using ‘pip install flask-uploads’
# try ‘pip install Flask-Reuploaded’
from flask_uploads import UploadSet, configure_uploads, IMAGES
from keras.preprocessing.image import load_img
# the pretrained model
from model import process_image, predict_class

app = Flask(__name__)

photos = UploadSet(‘photos’, IMAGES)

# path for saving uploaded images
app.config[‘UPLOADED_PHOTOS_DEST’] = ‘./static/img’
configure_uploads(app, photos)

# professionals have standards :p
@app.route(‘/home’, methods=[‘GET’, ‘POST’])
def home():
welcome = “Hello, World !”
return welcome

# the main route for upload and prediction
@app.route(‘/upload’, methods=[‘GET’, ‘POST’])
def upload():
if request.method == ‘POST’ and ‘photo’ in request.files:
# save the image
filename = photos.save(request.files[‘photo’])
# load the image
image = load_img(‘./static/img/’+filename, target_size=(224, 224))
# process the image
image = process_image(image)
# make prediction
prediction, percentage = predict_class(image)
# the answer which will be rendered back to the user
answer = “For {} :
The prediction is : {}
With probability = {}”.format(filename, prediction, percentage)
return answer
# web page to show before the POST request containing the image
return render_template(‘upload.html’)

if __name__ == ‘__main__’:
app.run(host=’127.0.0.1′, debug=True)

Please what did i do wrong?

2 Answers
Best Answer
Chris Staff answered 1 month ago

Your CuDNN failed to initialize. Some possible causes:

  • Your GPU is unavailable. This can be the case when you are already using it when trying to run this code, e.g. if you are already training another model on your GPU at the same time.
  • You are trying to run GPU based TensorFlow when you have no dedicated GPU in your machine.
  • A random initialization error, which can happen sometimes.

Possible fixes are to restart the script (possibly closing other GPU runs) or, if that does not work, to restart your computer.

Adesoji answered 1 month ago

Thanks sir, will do just that.

Your Answer

14 + 4 =