amd / RyzenAI-SW

MIT License
403 stars 65 forks source link

RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Exception during initialization: attrs_create_cif #107

Closed UdayUmesh closed 4 months ago

UdayUmesh commented 4 months ago

So I followed through the following Youtube Link Getting Started with Ryzen AI Software and after the installation I tried to do one of the tutorials , the hello_world one and I am facing an issue when I am trying to run the model on the IPU

Code Snippet:

`# Point to the config file path used for the VitisAI Execution Provider

config_file_path = "vaip_config.json"

aie_options = onnxruntime.SessionOptions()

aie_session = onnxruntime.InferenceSession( model.SerializeToString(), providers=['VitisAIExecutionProvider'], sess_options=aie_options, provider_options = [{'config_file': config_file_path, 'cacheDir': cache_directory, 'cacheKey': 'hello_cache'}] ) start = timer() npu_results = aie_session.run(None, {'input': input_data}) npu_total = timer() - start`

Error

`--------------------------------------------------------------------------- RuntimeException Traceback (most recent call last) Cell In[8], line 8 4 config_file_path = "vaip_config.json" 6 aie_options = onnxruntime.SessionOptions() ----> 8 aie_session = onnxruntime.InferenceSession( 9 model.SerializeToString(), 10 providers=['VitisAIExecutionProvider'], 11 sess_options=aie_options, 12 provider_options = [{'config_file': config_file_path, 13 'cacheDir': cache_directory, 14 'cacheKey': 'hello_cache'}] 15 ) 17 # Run Inference 18 start = timer()

File c:\Users\Uday U\anaconda3\envs\ryzenai-1.1-20240604-113611\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py:383, in InferenceSession.init(self, path_or_bytes, sess_options, providers, provider_options, **kwargs) 380 disabled_optimizers = kwargs["disabled_optimizers"] if "disabled_optimizers" in kwargs else None 382 try: --> 383 self._create_inference_session(providers, provider_options, disabled_optimizers) 384 except (ValueError, RuntimeError) as e: 385 if self._enable_fallback:

File c:\Users\Uday U\anaconda3\envs\ryzenai-1.1-20240604-113611\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py:435, in InferenceSession._create_inference_session(self, providers, provider_options, disabled_optimizers) 432 disabled_optimizers = set(disabled_optimizers) 434 # initialize the C++ InferenceSession --> 435 sess.initialize_session(providers, provider_options, disabled_optimizers) 437 self._sess = sess 438 self._sess_options = self._sess.session_options

RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Exception during initialization: attrs_create_cif attrs_create_cif (unknown) NLG_Return2 RtlCaptureContext2 public: virtual char const ptr64 cdecl pybind11::error_already_set::what(void)const __ptr64 public: virtual char const ptr64 cdecl pybind11::error_already_set::what(void)const __ptr64 PyInit_onnxruntime_pybind11_state PyInit_onnxruntime_pybind11_state PyInit_onnxruntime_pybind11_state PyInit_onnxruntime_pybind11_state PyInit_onnxruntime_pybind11_state PyInit_onnxruntime_pybind11_state PyInit_onnxruntime_pybind11_state PyInit_onnxruntime_pybind11_state PyInit_onnxruntime_pybind11_state PyInit_onnxruntime_pybind11_state PyInit_onnxruntime_pybind11_state public: void cdecl pybind11::error_already_set::discard_as_unraisable(class pybind11::object) __ptr64 PyCFunction_GetFlags _PyObject_MakeTpCall PyMethod_Self _PyOS_URandomNonblock PyEval_GetFuncDesc _PyEval_EvalFrameDefault _PyEval_EvalFrameDefault _PyFunction_Vectorcall _PyOS_URandomNonblock PyEval_GetFuncDesc _PyEval_EvalFrameDefault _PyEval_EvalFrameDefault _PyFunction_Vectorcall`

image

I would really appreciate if anybody could help me resolve this issue. Thank You

Here is the entire Jupyter Notebook for reference

hello_world_notebook.pdf

System: Venus UM790 Pro , Ryzen 9 7940HS

shivani-athavale commented 4 months ago

Hi @UdayUmesh

You could try out these steps:

  1. Install the ryzen-ai-sw-1.1 package and the NPU driver according to instructions at https://ryzenai.docs.amd.com/en/latest/inst.html

  2. Run 'quicktest.py' from the quicktest folder in the ryzen-ai-sw-1.1 package

  3. Go to https://github.com/amd/RyzenAI-SW and to the tutorial/hello_world folder

  4. Run 'pip install -r requirements.txt' and 'python hello_world.py' instead of running the Jupyter Notebook version of hello_world

UdayUmesh commented 4 months ago

I was a bit skeptical that following these steps would even work since I already did all these steps initially but to my surprise it resolved my issues .

I ran the 'hello_world.py' like you mentioned first ,

Screenshot 2024-07-28 110923

and it ran completely without any issues ,

even the notebook ran just fine

hello_world_notebook_2.pdf

Thank you @shivani-athavale