apple / coremltools

Core ML tools contain supporting tools for Core ML model conversion, editing, and validation.
https://coremltools.readme.io
BSD 3-Clause "New" or "Revised" License
4.22k stars 609 forks source link

Failed in runing predict() for Activation quantization model : Unknown opset 'CoreML7' #2116

Closed zzg-tju closed 5 months ago

zzg-tju commented 5 months ago

🐞Describing the bug

follow the "Training-Time Quantization" tutorial, I quantified the activation and weights of a model to int8, setting minimum_deployment_target = ct.target iOS17, but the converted mlpackage model reported an error when executing predict (): Error compiling model: "Failed to parse the model specification. Error: Unable to parse ML Program: at unknown location: Unknown opset'CoreML7 '."

when setting minimum_deployment_target = ct.target iOS16, another error: "ValueError: No available version for quantize in the coremltools.target.iOS16 opset. Please update the minimum_deployment_target to at least coremltools.target.iOS17"

Stack Trace

Traceback (most recent call last): File "/Users/test/Code/test/coreml_test.py", line 13, in output_dict = model.predict({'x': np.random.rand(*input_shape)}) File "/opt/homebrew/lib/python3.10/site-packages/coremltools/models/model.py", line 632, in predict raise self._framework_error File "/opt/homebrew/lib/python3.10/site-packages/coremltools/models/model.py", line 152, in _get_proxy_and_spec return _MLModelProxy(filename, compute_units.name), specification, None RuntimeError: Error compiling model: "Failed to parse the model specification. Error: Unable to parse ML Program: at unknown location: Unknown opset 'CoreML7'.".

System environment (please complete the following information):

TobyRoseman commented 5 months ago

It looks like you need to update your MacOS to Sonoma.

zzg-tju commented 5 months ago

It looks like you need to update your MacOS to Sonoma.

yes, after update to MacOS14, problem solved. In addition, I found that setting minimum_deployment_target = ct.target iOS 17 on linux, the converted mlmodel can predict on macos14 normally; but when converting the model on mac, you must ensure that macos > = 14 =-=