cansik / onnxruntime-silicon

ONNX Runtime prebuilt wheels for Apple Silicon (M1 / M2 / M3 / ARM64)
MIT License
196 stars 18 forks source link

ModuleNotFoundError: No module named 'onnxruntime-silicon' #2

Closed halfperim closed 1 year ago

halfperim commented 1 year ago

Hi, I just installed onnxruntime-silicon (it appears in my pip list) but struggle to import it. If I just type in 'import onnxruntime-silicon' I get a 'SyntaxError: invalid syntax' probably because of the '-'. I tried using importlib to import the module (by typing onnxsilicon = importlib.import_module('onnxruntime-silicon') ) but I still get an error (ModuleNotFoundError: No module named 'onnxruntime-silicon').

Could you please help me to import the module? Thanks!

cansik commented 1 year ago

It's a drop in replacement of onnxruntime which means you can just use the original module name:

import onnxruntime
halfperim commented 1 year ago

Hi cansik, Thank your for taking the time to answer! When I type in import onnxruntime in the python prompt I still get an error (ModuleNotFoundError: No module named 'onnxruntime') despite onnxruntime-silicon appearing in pip list

wenching33 commented 1 year ago

I have the same issue. Using import onnxruntime when no original onnxruntime installed, it shows ModuleNotFoundError. Has anyone solved this ?

yeldarby commented 1 year ago

Same issue

Update: my issue was Python 3.11. Creating a venv with 3.10 worked. But oddly it’s 3x slower than the CPU Execution Provider on my M1 Max.

cansik commented 1 year ago

@yeldarby Yes it could be that it is slower, but this has to do with the ops that are supported by onnxruntime with coreml. If your model is using a lot of ops which are not supported, the CPU / GPU have to exchange a lot of data which makes it even slower.

Could you please explain a bit more why 3.11 did not work for you? Could you install the package?

yeldarby commented 1 year ago

It’s because onnxruntime didn’t add support for Python 3.11 until 1.15.0 and this is based on 1.13.0.

cansik commented 1 year ago

@yeldarby That seems not correct, onnxruntime-silicon is based on 1.15.0 and 3.11 is prebuilt and supported. Did you install the correct version?

yeldarby commented 1 year ago

This version adds the CoreML backend with version v1.13.0.

Weird, I must have misunderstood what this meant.

I guess now I'm not sure why it worked with 3.10 and not 3.11. I was getting the error from #3 where PyPi couldn't find anything to install.

cansik commented 1 year ago

This means that CoreML backend has been added in version 1.13.0, but of course is supported in later versions. CoreML is just another backend, but the CPU backend was in onnxruntime-silicon form the beginning on. If you have the same problem as in #3, you most likely have the Intel version of python installed.

cansik commented 1 year ago

I am closing this issue as it has not been possible to reproduce the error on a correctly configured system. Please refer to the newly created Frequently Asked Questions for help.