在尝试获取我的bad_alloc
模型时,我遇到了.tflite
异常,
iOS Tensorflow示例之一。
这是获取模型的代码:
// Construct the path to the model file.
guard let modelPath = Bundle.main.path(
forResource: modelFilename,
ofType: modelFileInfo.extension
) else {
print("Failed to load the model file with name: \(modelFilename).")
return nil
}
// Specify the options for the `Interpreter`.
self.threadCount = threadCount
var options = InterpreterOptions()
options.isErrorLoggingEnabled = true
options.threadCount = threadCount
do {
// Create the `Interpreter`.
interpreter = try Interpreter(modelPath: modelPath, options: options)
// Allocate memory for the model's input `Tensor`s.
try interpreter.allocateTensors()
} catch let error {
print("Failed to create the interpreter with error: \(error.localizedDescription)")
return nil
}
super.init()
以下是日志:
2019-06-26 15:25:45.414765+0300 Celly[5485:1152189] Initialized TensorFlow Lite runtime.
Celly(5485,0x1006aebc0) malloc: can't allocate region
*** mach_vm_map(size=1800945664) failed (error code=3)
Celly(5485,0x1006aebc0) malloc: *** set a breakpoint in malloc_error_break to debug
libc++abi.dylib: terminating with uncaught exception of type std::bad_alloc: std::bad_alloc
是否有已知的解决方法或文档的帮助?模型是否存在问题,因此需要对其进行优化或适当配置?