hollance / coreml-survival-guide

Source code for the book Core ML Survival Guide
MIT License
250 stars 36 forks source link

Insufficient Permission (to submit GPU work from background) when running MobileNetV2+SSDLite code with my own model #3

Open MarkTension opened 5 years ago

MarkTension commented 5 years ago

Hi there! Really appreciate your work on explaining CoreML. Super useful! I cloned your repository to learn about implementing CoreML and to find out how well my SSD_mobilenet_V1 trained on one class via tensorflow object detection API works. I replaced your MobileNetV2_SSDLite.mlmodel with my MobileNetV1_SSD.mlmodel, and changed the coreMLModel variable in the viewcontroller.

Unfortunately it doesn't work. The console output lists two problems:

The example does work with the originally supplied mobilenet_V2. I'm running on iOS12. I've verified my model's accuracy on tensorboard, which is quite good, and I've followed your tutorial to convert it to .mlmodel and made sure to change the code for my one-class model.

Failed to perform Vision request: Error Domain=com.apple.vis Code=3 "The VNCoreMLTransform request failed" UserInfo={NSLocalizedDescription=The VNCoreMLTransform request failed, NSUnderlyingError=0x28019f2d0 {Error Domain=com.apple.CoreML Code=0 "Failed to evaluatue model 1 in pipeline" UserInfo={NSLocalizedDescription=Failed to evaluatue model 1 in pipeline, NSUnderlyingError=0x28019e910 {Error Domain=com.apple.CoreML Code=0 "Shape (91 x 1 x 1917) was not in enumerated set of allowed shapes" UserInfo={NSLocalizedDescription=Shape (91 x 1 x 1917) was not in enumerated set of allowed shapes}}}}} 2019-01-22 13:09:23.913001+0100 ObjectDetection[1428:73469] Execution of the command buffer was aborted due to an error during execution. Insufficient Permission (to submit GPU work from background) (IOAF code 6) 2019-01-22 13:09:23.913428+0100 ObjectDetection[1428:73469] Execution of the command buffer was aborted due to an error during execution. Insufficient Permission (to submit GPU work from background) (IOAF code 6) Error: command buffer exited with error status. The Metal Performance Shaders operations encoded on it may not have completed. Error: (null) Insufficient Permission (to submit GPU work from background) (IOAF code 6) <AGXA9FamilyCommandBuffer: 0x12fd4ab00> label = <none> device = <AGXA9Device: 0x105818000> name = Apple A9 GPU commandQueue = <AGXA9FamilyCommandQueue: 0x12fe1a5a0> label = <none> device = <AGXA9Device: 0x105818000> name = Apple A9 GPU retainedReferences = 1

hollance commented 5 years ago

Are you trying to run the model while the app is backgrounded?

91 is indeed the number of COCO classes + the background.

MarkTension commented 5 years ago

I'm not, interestingly enough. Only change made to the code was swap models, and changed to the new model's name. Is the 91 defined somewhere in the app's code? Can't seem to find it. Model's specs seem alright? Or have I probably messed up my model in some way?

screenshot
hollance commented 5 years ago

That 91 is somewhere in your model.

MarkTension commented 5 years ago

Riight! Thanks. Turned out I forgot to change the number of classes in the training config file, while setting number of classes in the .pb to .mlmodel conversion to 1. Interestingly enough, it also solved the GPU on the background error, and my model worked!

hollance commented 5 years ago

Good to hear. That "GPU on background" error was probably just a misleading error message that was triggered by the error with the shapes.