简体   繁体   English

在 CPU 中使用 flask 加载预训练的 model

[英]load pre-trained model using flask in CPU

I trained a model using machine learning algorithms, and I want to deploy this model using Flask.我使用机器学习算法训练了一个 model,我想使用 Flask 部署这个 model。 but as ı don't have GPU I am using my computer CPU to load the model and that's where I am getting errors.但是因为我没有 GPU 我正在使用我的计算机 CPU 来加载 model,这就是我遇到错误的地方。 how I can ignore GPU?我怎么能忽略 GPU?

load.py加载.py

import numpy as np
import keras.models
from keras.models import model_from_json
import tensorflow as tf

def model():
    json_file = open("model.json",'r')
    load_json_model = json_file.read()
    json_file.close()

    load_model = model_from_json(load_json_model)
    load_model.load_weights("model.h5")

    load_model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])


errors错误

2021-02-13 10:48:53.891534: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-02-13 10:48:53.907500: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.

self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

It looks like this is a duplicate of this question: Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation看起来这是这个问题的副本: Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation

However, this is a warning not an error.但是,这是警告而不是错误。 (The log line starts with a W ). (日志行以W开头)。

Try the following to resolve the issue:尝试以下方法来解决问题:

  • Make sure model.h5 and models.json are in the same folder as your script确保model.h5models.json与您的脚本位于同一文件夹中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM