-
Notifications
You must be signed in to change notification settings - Fork 190
Build succeeded but "Fatal error: Can't find the model file!" #86
Comments
Fixed!!! [Speech Recognition] But the HelloWorld code still remains bugged! |
I'm also having this problem with the EDIT: I can also confirm that I've tried modifying ViewController.swift:8 to a few things:
But didn't have any luck. |
Has anyone else been able to reproduce this? Very excited to try PyTorch mobile development, but I can't really move beyond the HelloWorld at this point! |
Just tried on Xcode 14.0.1 on a M1 Mac. Same error. I do see this warning though, am not sure they are related.
|
use python 3.6.x and install torch 1.10.x then run python trace_model.py |
The Error message is actually kind of misleading. It's trying to do two things at once:
It throws the private lazy var module: TorchModule = {
let modelName = "model"
if let filePath = Bundle.main.path(forResource: modelName, ofType: "ptl") {
// Ok, found the model file
} else {
fatalError("Can't find the model file!")
}
if let filePath = Bundle.main.path(forResource: modelName, ofType: "ptl"),
let module = TorchModule(fileAtPath: filePath) {
return module
} else {
fatalError("Can't load TorchModule!")
}
}() If now you get a different error message, the problem is the structure of the model. For example, for me I got If you still get the same error message, you have to add the file to Xcode.(XCode uses a it's internal filesystem that is not the same as the native filesystem)
|
I read several answers here, and realized the reason is the different version between LibTorch-Lite and Pytorch. In my case, the Pytorch version is 2.0. Both Pytorch 2.0 and LibTorch-Lite 1.13.0.1 are the latest version at this moment. |
Thanks @ho0-kim! PyTorch versioning has given me a lot of pain 😅 |
I was hitting the same issue (that the model file exists, but it can't be parsed by TorchModule). As @cyrillkuettel and @ho0-kim pointed out, this issue is due to the version mismatch between LibTorch-Lite and Pytorch. Here is my solution.
Then cmd+R to run it, and the app runs successfully. |
I have just ran the Hello World and Speech Recognition code, following all of the steps. The build was successful but after that the Hello World code did not show up the picture and the Speech Recognition code did not return the word I said (although the interface with "Start" and "Listening" still showed up)
I also checked the model file and it was at the right folder with the ViewController
The full output is "SpeechRecognition[47748:2353702] SpeechRecognition/ViewController.swift:36: Fatal error: Can't find the model file!"
The text was updated successfully, but these errors were encountered: