What Do I Do If "AttributeError: module 'onnxruntime' has no attribute 'SessionOption'" Is Displayed When Compiling and Installing a Custom Operator Package?
Symptom
When compiling and installing a custom operator package during the AMCT installation, "AttributeError: module 'onnxruntime' has no attribute 'SessionOption'" displays; the compilation terminates and AMCT is unavailable.
Possible Cause
In the Python environment, the SessionOption attribute of ONNX Runtime is missing. The possible reason is that the library is abnormal or is of an unmatched version
Solution
- Check whether the ONNX Runtime version meets the environment requirements (as described in Checking the OS Requirements and Environment). If not, install the required version.
- In the Python environment, run the import onnxruntime command to check the ONNX Runtime version and path. If AttributeError persists, run the following command to forcibly reinstall ONNX Runtime:
pip3 install --force-reinstall onnxruntime==1.x.x --user
Another possible cause is that you had installed both onnxruntime and onnxruntime_gpu but have uninstalled one of them, which may affect the functionality of the other.
Parent topic: FAQ