我使用机器学习算法训练了一个模型,我想使用Flask部署这个模型。但由于我没有GPU,我正在使用我的计算机CPU来加载模型,这就是我得到错误的地方。我怎么能忽略GPU?
load.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'])
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
看起来这是这个问题的重复:无法加载动态库'cudart64_101.dll'关于tensorflow cpu安装
然而,这是一个警告而不是一个错误。(日志行以W
开头)
尝试以下操作来解决问题:
- 确保
model.h5
和models.json
与脚本在同一文件夹