amd / RyzenAI-SW

MIT License
405 stars 65 forks source link

can not run getting_started_resnet tutorial with AMD Phoenix (PHX) platform (Ryzen 7 7840H) #120

Closed mattchai closed 2 months ago

mattchai commented 2 months ago

phoniex

getting_started_resnet tutorial can run on AMD Strix point platform, but can not run on AMD Phoenix (PHX) platform.

shivani-athavale commented 2 months ago

Hi @mattchai, the getting_started_resnet tutorial should be able to run on PHX. The following steps need to be ensured:

  1. Some environment variables are set for STX by default, they need to be set as following for PHX.

    set XLNX_VART_FIRMWARE=%RYZEN_AI_INSTALLATION_PATH%/voe-4.0-win_amd64/xclbins/phoenix/1x4.xclbin
    set XLNX_TARGET_NAME=AMD_AIE2_Nx4_Overlay

    The instructions are also available at https://ryzenai.docs.amd.com/en/latest/runtime_setup.html#npu-configurations

  2. Make sure to delete the cache folder before every inference run. (It is named 'modelcachekey' and is created in the getting_started_resnet folder.)

mattchai commented 2 months ago

It can work after delete the cache folder, i will close this issue

mattchai commented 2 months ago

@shivani-athavale , still can't work on Hawk(HPT) (R9 8945HS) platform, error message as below, please help to check it, thanks.

Screenshot 2024-09-25 015349

(ryzen-ai-1.2.0) C:\getting_started_resnet>rmdir /s /q modelcachekey

(ryzen-ai-1.2.0) C:\getting_started_resnet>set XLNX_VART_FIRMWARE=%RYZEN_AI_INSTALLATION_PATH%/voe-4.0-win_amd64/xclbins/phoenix/1x4.xclbin

(ryzen-ai-1.2.0) C:\getting_started_resnet>set XLNX_TARGET_NAME=AMD_AIE2_Nx4_Overlay

(ryzen-ai-1.2.0) C:\getting_started_resnet>python predict.py --ep npu WARNING: Logging before InitGoogleLogging() is written to STDERR E20240925 01:51:43.794515 10400 xclbin_file.cpp:101] Failed to open xclbin C:\Windows\System32\AMD\%RYZEN_AI_INSTALLATION_PATH%/voe-4.0-win_amd64/xclbins/phoenix/1x4.xclbin E20240925 01:51:44.213496 10400 xclbin_file.cpp:101] Failed to open xclbin C:\Windows\System32\AMD\%RYZEN_AI_INSTALLATION_PATH%/voe-4.0-win_amd64/xclbins/phoenix/1x4.xclbin E20240925 01:51:52.526823 10400 xclbin_file.cpp:101] Failed to open xclbin C:\Windows\System32\AMD\%RYZEN_AI_INSTALLATION_PATH%/voe-4.0-winamd64/xclbins/phoenix/1x4.xclbin [Vitis AI EP] No. of Operators : CPU 2 NPU 398 [Vitis AI EP] No. of Subgraphs : CPU 1 NPU 1 Actually running on NPU 1 ← [ 0 ; 9 3 m 2 0 2 4 - 0 9 - 2 5 0 1 : 5 1 : 5 2 . 6 3 8 0 2 9 1 [ W : o n n x r u n t i m e : , s e s s i o n s t a t e . c c : 1 1 6 6 o n n x r u n t i m e : : V e r i f y E a c h N o d e I s A s s i g n e d T o A n E p ] S o m e n o d e s w e r e n o t a s s i g n e d t o t h e p r e f e r r e d e x e c u t i o n p r o v i d e r s w h i c h m a y o r m a y n o t h a v e a n n e g a t i v e i m p a c t o n p e r f o r m a n c e . e . g . O R T e x p l i c i t l y a s s i g n s s h a p e r e l a t e d o p s t o C P U t o i m p r o v e p e r f . ← [ m ← [ 0 ; 9 3 m 2 0 2 4 - 0 9 - 2 5 0 1 : 5 1 : 5 2 . 6 4 4 1 1 6 6 [ W : o n n x r u n t i m e : , s e s s i o n _ s t a t e . c c : 1 1 6 8 o n n x r u n t i m e : : V e r i f y E a c h N o d e I s A s s i g n e d T o A n E p ] R e r u n n i n g w i t h v e r b o s e o u t p u t o n a n o n - m i n i m a l b u i l d w i l l s h o w n o d e a s s i g n m e n t s . ← [ m F20240925 01:51:52.939664 10400 customop.cpp:368] -- Error: Failed to create GE handle: Error: No compatible xclbin file found. ← [ 1 ; 3 1 m 2 0 2 4 - 0 9 - 2 5 0 1 : 5 1 : 5 2 . 9 8 1 3 1 2 8 [ E : o n n x r u n t i m e : , i n f e r e n c e s e s s i o n . c c : 1 9 3 5 o n n x r u n t i m e : : I n f e r e n c e S e s s i o n : : I n i t i a l i z e : : < l a m b d a 2 a 0 e 0 9 6 4 6 3 d 5 3 c e b 1 6 5 4 2 7 f a 1 4 e 8 0 3 7 a > : : o p e r a t o r ( ) ] E x c e p t i o n d u r i n g i n i t i a l i z a t i o n : p u b l i c : v i r t u a l c d e c l g o o g l e : : p r o t o b u f : : S t r u c t : : ~ S t r u c t ( v o i d ) p t r 6 4 p u b l i c : v i r t u a l u n s i g n e d c h a r * p t r 6 4 c d e c l g o o g l e : : p r o t o b u f : : i n t e r n a l : : Z e r o F i e l d s B a s e : : I n t e r n a l S e r i a l i z e ( u n s i g n e d c h a r p t r 6 4 , c l a s s g o o g l e : : p r o t o b u f : : i o : : E p s C o p y O u t p u t S t r e a m p t r 6 4 ) c o n s t p t r 6 4 C x x F r a m e H a n d l e r 4 ( u n k n o w n ) R t l C a p t u r e C o n t e x t 2 p u b l i c : v o i d c d e c l v a i p c o r e : : D p u S u b g r a p h E n t r y P r o t o : : u n s a f e a r e n a s e t a l l o c a t e d t r y f u s e ( c l a s s v a i p c o r e : : T r y F u s e P r o t o * p t r 6 4 ) p t r 6 4 p u b l i c : v o i d c d e c l v a i p c o r e : : D p u S u b g r a p h E n t r y P r o t o : : u n s a f e a r e n a s e t a l l o c a t e d t r y f u s e ( c l a s s v a i p c o r e : : T r y F u s e P r o t o p t r 6 4 ) p t r 6 4 ( u n k n o w n ) P y I n i t o n n x r u n t i m e p y b i n d 1 1 s t a t e P y I n i t o n n x r u n t i m e p y b i n d 1 1 s t a t e P y I n i t o n n x r u n t i m e p y b i n d 1 1 s t a t e P y I n i t o n n x r u n t i m e p y b i n d 1 1 s t a t e P y I n i t o n n x r u n t i m e p y b i n d 1 1 s t a t e P y I n i t o n n x r u n t i m e p y b i n d 1 1 s t a t e P y I n i t o n n x r u n t i m e p y b i n d 1 1 s t a t e P y I n i t o n n x r u n t i m e p y b i n d 1 1 s t a t e P y I n i t o n n x r u n t i m e p y b i n d 1 1 s t a t e P y I n i t o n n x r u n t i m e p y b i n d 1 1 s t a t e p u b l i c : v o i d c d e c l p y b i n d 1 1 : : e r r o r a l r e a d y s e t : : d i s c a r d a s u n r a i s a b l e ( c l a s s p y b i n d 1 1 : : o b j e c t ) p t r 6 4 P y C F u n c t i o n G e t F l a g s P y O b j e c t M a k e T p C a l l P y M e t h o d S e l f P y O S U R a n d o m N o n b l o c k P y E v a l G e t F u n c D e s c P y E v a l E v a l F r a m e D e f a u l t P y E v a l E v a l F r a m e D e f a u l t P y F u n c t i o n V e c t o r c a l l P y O S U R a n d o m N o n b l o c k P y E v a l G e t F u n c D e s c P y E v a l E v a l F r a m e D e f a u l t P y E v a l E v a l F r a m e D e f a u l t P y F u n c t i o n V e c t o r c a l l ← [ m Traceback (most recent call last): File "C:\getting_started_resnet\predict.py", line 36, in session = ort.InferenceSession(model.SerializeToString(), providers=providers, File "C:\ProgramData\anaconda3\envs\ryzen-ai-1.2.0\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 419, in init self._create_inference_session(providers, provider_options, disabled_optimizers) File "C:\ProgramData\anaconda3\envs\ryzen-ai-1.2.0\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 483, in _create_inference_session sess.initialize_session(providers, provider_options, disabled_optimizers) onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Exception during initialization: public: virtual cdecl google::protobuf::Struct::~Struct(void) ptr64 public: virtual unsigned char ptr64 cdecl google::protobuf::internal::ZeroFieldsBase::_InternalSerialize(unsigned char __ptr64,class google::protobuf::io::EpsCopyOutputStream ptr64)const ptr64 CxxFrameHandler4 (unknown) RtlCaptureContext2 public: void cdecl vaip_core::DpuSubgraphEntryProto::unsafe_arena_set_allocated_try_fuse(class vaip_core::TryFuseProto ptr64) ptr64 public: void __cdecl vaip_core::DpuSubgraphEntryProto::unsafe_arena_set_allocated_try_fuse(class vaip_core::TryFuseProto ptr64) ptr64 (unknown) 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

(ryzen-ai-1.2.0) C:\getting_started_resnet>

shivani-athavale commented 2 months ago

Hi @mattchai,

Can you try checking your %RYZEN_AI_INSTALLATION_PATH%?

As mentioned in the documentation at , RyzenAI should be installed at the path C:\Program Files\RyzenAI\1.2.0 by default.

In your error logs, the path is shown as: C:\Windows\System32\AMD%RYZEN_AI_INSTALLATION_PATH%. Maybe this path has been set wrong which is why the xclbin is not found.

You could try the installation steps and ensure the environment variables are set correctly.

mattchai commented 2 months ago

Hi @shivani-athavale, RyzenAI path is correct, I got the error during first time running, it can run without any error after the second attempt, thanks.

uday610 commented 2 months ago

Closing this issue as it is resolved