Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac.dlopen returns null instead of libundreamai_macos-*64-acc.dylib #275

Open
CGAleksey opened this issue Nov 22, 2024 · 12 comments
Open

Mac.dlopen returns null instead of libundreamai_macos-*64-acc.dylib #275

CGAleksey opened this issue Nov 22, 2024 · 12 comments
Labels
bug Something isn't working

Comments

@CGAleksey
Copy link

Describe the bug

I tried to run LLM on MacBook Pro:

  • OSX BigSur 11.7.10
  • Model Identifier: MacBookPro11,3.
    As far as I see something goes wrong at line 141: handle = Mac.dlopen(libraryName);
    handle always contains null even if I manually (during runtime in VS) corrected libraryName for 4 possible options (arm64 or x64).

I used "Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf"

Steps to reproduce

Just run it on OSX, hit play button and you wil see in console:
LLM service couldn't be created
#0 GetStacktrace(int)
#1 DebugStringToFile(DebugStringToFileData const&)
#2 DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)
#3 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)

LLMUnity version

v2.3.0

Operating System

macOs

@CGAleksey CGAleksey added the bug Something isn't working label Nov 22, 2024
@CGAleksey CGAleksey changed the title Mac.dlopen return null instead libundreamai_macos-*64-acc.dylib Mac.dlopen returns null instead of libundreamai_macos-*64-acc.dylib Nov 22, 2024
@CGAleksey
Copy link
Author

I noticed OSX BigSur 11.7.10 doesn't have file: /usr/lib/libSystem.dylib

@amakropoulos
Copy link
Collaborator

Thank you for submitting the issue!
Could you check if changing this line

private const string SystemLibrary = "/usr/lib/libSystem.dylib";

to
private const string SystemLibrary = "libSystem.B.dylib";
works for BigSur?

@CGAleksey
Copy link
Author

CGAleksey commented Nov 25, 2024

I tried this:
private const string SystemLibrary = "/usr/lib/libSystem.B.dylib";

In build (Player.log) I see errors:

_LLM service couldn't be created
#0 GetStacktrace(int)
#1 DebugStringToFile(DebugStringToFileData const&)
#2 DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)
#3 DebugLogHandler_Internal_Log_m20852F18A88BB18425BA07260545E3968F7EA76C
#4 DebugLogHandler_LogFormat_m216B169EF9B669F2ED4C59F6B9F326D4EBBDF821
#5 InterfaceActionInvoker4<int, Object_tC12DECB6760A7F2CBF65D9DCF18D044C2D97152C*, String_t*, ObjectU5BU5D_t8061030B0A12A55D5AD8652A20C922FE99450918*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, int, Object_tC12DECB6760A7F2CBF65D9DCF18D044C2D97152C*, String_t*, ObjectU5BU5D_t8061030B0A12A55D5AD8652A20C922FE99450918*)
#6 Logger_Log_mEA3D39763D610E92491AA479BA653ECFEE3E9E5C
#7 InterfaceActionInvoker2<int, Il2CppObject*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, int, Il2CppObject*)
#8 Debug_LogError_mB00B2B4468EF3CAF041B038D840820FB84C924B2
#9 LLMUnitySetup_LogError_m699765872C2C3A8B454FE2B909DAFC8A0ED2CAE3
#10 LLM_StartLLMServer_m7EC22542FA372186FDBECFE771C60CD8CCBBE8B9
#11 U3CU3Ec__DisplayClass55_0_U3CAwakeU3Eb__0_mEF8107541E2BA3BA472FF4ED5AA38A9A9ABBC622
#12 Task_InnerInvoke_m4FA9E513B4B539A5AC1C40D1EF4CA85544918366
#13 VirtualActionInvoker0::Invoke(unsigned short, Il2CppObject*)
#14 Task_Execute_m4FBCBCE932B924AD239A2448AED5708B6D14A7F1
#15 Task_ExecutionContextCallback_m72CB65AAA76D5FB962E36EC25AAC150A04EB47B3
#16 ContextCallback_Invoke_m872CCCD40428B88C2612772491BE5157895B5F61_OpenStatic(ContextCallback_tE8AFBDBFCC040FDA8DA8C1EEFE9BD66B16BDA007*, Il2CppObject*, MethodInfo const*)
#17 ExecutionContext_RunInternal_mC37E85D6FC972DF219A00FE1EE34329D1D63CC94
#18 ExecutionContext_Run_m6E5E07E0131DA97C6BC235754A0682CFFACE7BF8
#19 Task_ExecuteWithThreadLocal_mD3F4E7ADBBC473EAF7C24B3A785EBB452D6A76BE
#20 Task_ExecuteEntry_m735BD89474854D6EAA2ED929D6765AF1B4AEDCDF
#21 Task_System_Threading_IThreadPoolWorkItem_ExecuteWorkItem_mAEE759CC728F27B64F95C7B6C6E22FCD7E6F8801
#22 InterfaceActionInvoker0::Invoke(unsigned short, Il2CppClass*, Il2CppObject*)
#23 ThreadPoolWorkQueue_Dispatch_mEAAC936B3756DAA856BA3A4D976A98A3184CDC87
#24 _ThreadPoolWaitCallback_PerformWaitCallback_m6D08BAF0E0D909F86341B3EFBABCF294074C0B00
#25 RuntimeInvoker_FalseByte_t94D9231AC217BE4D2E004C4CD32DF6D099EA41A3(void ()(), MethodInfo const, void*, void**, void*)
#26 il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**)
#27 worker_thread(void*)
#28 il2cpp::vm::ThreadStart(void*)
#29 il2cpp::os::Thread::RunWrapper(void*)
#30 il2cpp::os::ThreadImpl::ThreadStartWrapper(void*)
#31 pthread_start
#32 thread_start

LLM service couldn't be created
#0 GetStacktrace(int)
#1 DebugStringToFile(DebugStringToFileData const&)
#2 DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)
#3 DebugLogHandler_Internal_Log_m20852F18A88BB18425BA07260545E3968F7EA76C
#4 DebugLogHandler_LogFormat_m216B169EF9B669F2ED4C59F6B9F326D4EBBDF821
#5 InterfaceActionInvoker4<int, Object_tC12DECB6760A7F2CBF65D9DCF18D044C2D97152C*, String_t*, ObjectU5BU5D_t8061030B0A12A55D5AD8652A20C922FE99450918*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, int, Object_tC12DECB6760A7F2CBF65D9DCF18D044C2D97152C*, String_t*, ObjectU5BU5D_t8061030B0A12A55D5AD8652A20C922FE99450918*)
#6 Logger_Log_mEA3D39763D610E92491AA479BA653ECFEE3E9E5C
#7 InterfaceActionInvoker2<int, Il2CppObject*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, int, Il2CppObject*)
#8 Debug_LogError_mB00B2B4468EF3CAF041B038D840820FB84C924B2
#9 LLMUnitySetup_LogError_m699765872C2C3A8B454FE2B909DAFC8A0ED2CAE3
#10 LLM_AssertStarted_mAF658DF13FC239B2C0E190280AF793E56DDFF9E5
#11 U3CTokenizeU3Ed__96_MoveNext_m11D294F8ABBB33E41078DC407AC72D35AFAB50B1
#12 InterfaceActionInvoker0::Invoke(unsigned short, Il2CppClass*, Il2CppObject*)
#13 AsyncTaskMethodBuilder_1_Start_TisRuntimeObject_m4CC6B9A3F0DD032BDFC0B8416CE27980382ED173_gshared
#14 AsyncTaskMethodBuilder_1_Start_TisU3CTokenizeU3Ed__96_tB9A33EC8B491341F11815D12FB164C826BFFE3EB_m6E913221C7A88784DA8F0ED896F44C34609ED2B1(AsyncTaskMethodBuilder_1_tA28B0962049DC249BEC0054E2394B1962E28E90E*, U3CTokenizeU3Ed__96_tB9A33EC8B491341F11815D12FB164C826BFFE3EB**, MethodInfo const*)
#15 LLM_Tokenize_m06B188973886A3EAC73C42784FAA9F14362D0A34
#16 U3CPostRequestLocalU3Ed__29_2_MoveNext_mD1B6EE9A9D96635063445F4307C0E7C5F280FCAF_gshared
#17 InterfaceActionInvoker0::Invoke(unsigned short, Il2CppClass*, Il2CppObject*)
#18 MoveNextRunner_InvokeMoveNext_m4B7F4130C989B244668A0A57017A6C308E54D215
#19 ContextCallback_Invoke_m872CCCD40428B88C2612772491BE5157895B5F61_OpenStatic(ContextCallback_tE8AFBDBFCC040FDA8DA8C1EEFE9BD66B16BDA007*, Il2CppObject*, MethodInfo const*)
#20 ExecutionContext_RunInternal_mC37E85D6FC972DF219A00FE1EE34329D1D63CC94
#21 ExecutionContext_Run_m6E5E07E0131DA97C6BC235754A0682CFFACE7BF8
#22 MoveNextRunner_Run_m86395F123FB453F2B5FF89CE1E98532F7426F9DE
#23 YieldAwaiter_RunAction_mC611EE7A89483B65F4CA6D5362789551201309E0
#24 SendOrPostCallback_Invoke_m23B949AF9D78E8635F84E1E7775A50472B4F9C28_OpenStatic(SendOrPostCallback_t5C292A12062F24027A98492F52ECFE9802AA6F0E*, Il2CppObject*, MethodInfo const*)
#25 WorkRequest_Invoke_mBFEC6A3799BAFDE7ED840A0523D3D56160C03921
#26 UnitySynchronizationContext_Exec_m7E6352CBA70E4AB14F7D50A919C3F8C22F2E977A
#27 UnitySynchronizationContext_ExecuteTasks_m3034D59292339809C6D7FA5932ACC365892B8CA1
#28 RuntimeInvoker_FalseVoid_t4861ACF8F4594C3437BB48B6E56783494B843915(void ()(), MethodInfo const, void*, void**, void*)
#29 il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**)
#30 il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**)
#31 il2cpp_runtime_invoke
#32 scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)
#33 ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)
#34 Scripting::UnityEngine::UnitySynchronizationContextProxy::ExecuteTasks(ScriptingExceptionPtr*)
#35 InitPlayerLoopCallbacks()::UpdateScriptRunDelayedTasksRegistrator::Forward()
#36 ExecutePlayerLoop(NativePlayerLoopSystem*)
#37 ExecutePlayerLoop(NativePlayerLoopSystem*)
#38 PlayerLoop()
#39 -[PlayerAppDelegate UpdatePlayer]
#40 -[PlayerAppDelegate TimerTick]
#41 __NSFireTimer
#42 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION
#43 __CFRunLoopDoTimer
#44 __CFRunLoopDoTimers
#45 __CFRunLoopRun
#46 CFRunLoopRunSpecific
#47 RunCurrentEventLoopInMode
#48 ReceiveNextEventCommon
#49 _BlockUntilNextEventMatchingListInModeWithFilter
#50 _DPSNextEvent
#51 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
#52 -[NSApplication run]
#53 NSApplicationMain
#54 PlayerMain(int, char const**)
#55 start

In Unity Editor I tried to click Play button and nothing happened for 5 mins.
Looks like something freezeв, I can't type anything into input field.

Also tried this option:

            private const string SystemLibrary1 = "libdl.dylib";

            [DllImport ( SystemLibrary1, EntryPoint = "dlopen" )]
            public static extern IntPtr dlopen1 ( string path, int mode );
            [DllImport ( SystemLibrary1, EntryPoint = "dlsym" )]
            public static extern IntPtr dlsym1 ( IntPtr handle, string symbol );
            [DllImport ( SystemLibrary1, EntryPoint = "dlclose" )]
            public static extern void dlclose1 ( IntPtr handle );
            [DllImport ( SystemLibrary1, EntryPoint = "dlerror" )]
            private static extern IntPtr dlerror1 ();

            private const int RTLD_LAZY = 1;
            private const int RTLD_NOW = 2;

            public static IntPtr LoadLibrary ( string path, bool lazy = true ) {
                IntPtr h = dlopen1 ( path, lazy ? RTLD_LAZY : RTLD_NOW );
                var errPtr = dlerror1 ();
                if (errPtr != IntPtr.Zero) {
                    UnityEngine.Debug.LogError ( Marshal.PtrToStringAnsi ( errPtr ) );
                }
                return h;
            }

            public static IntPtr GetSymbol ( IntPtr libraryHandle, string symbol ) {
                return dlsym1 ( libraryHandle, symbol );
            }

            public static void UnloadLibrary ( IntPtr libraryHandle ) {
                dlclose1 ( libraryHandle );
            }// */

Console output:

_dlopen(/Volumes/Samsung_T5/LLM/Assets/StreamingAssets/undreamai-v1.1.13-llamacpp/macos-x64-no_acc/libundreamai_macos-x64-no_acc.dylib, 1): Symbol not found: __ZNKSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE3strEv
Referenced from: /Volumes/Samsung_T5/LLM/Assets/StreamingAssets/undreamai-v1.1.13-llamacpp/macos-x64-no_acc/libundreamai_macos-x64-no_acc.dylib (which was built for Mac OS X 12.7)
Expected in: /usr/lib/libc++.1.dylib

#0 GetStacktrace(int)
#1 DebugStringToFile(DebugStringToFileData const&)
#2 DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)
#3 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)_

@amakropoulos
Copy link
Collaborator

Could you try without the "/usr/lib/" part as well?

@CGAleksey
Copy link
Author

CGAleksey commented Nov 25, 2024

Could you try without the "/usr/lib/" part as well?

Sorry, replaced to:
private const string SystemLibrary = "libSystem.B.dylib";

UnityEditor doesn't react on input.

Player.log of build:

Found 1 interfaces on host : 0) 192.168.1.86
Multi-casting "[IP] 192.168.1.86 [Port] 55000 [Flags] 2 [Guid] 1999621394 [EditorId] 1876488654 [Version] 1048832 [Id] OSXPlayer(1,Hello-PC) [Debug] 0 [PackageName] OSXPlayer [ProjectName] LLM" to [225.0.0.222:54997]...
[Physics::Module] Initialized MultithreadedJobDispatcher with {0} workers.
Initialize engine version: 2021.3.45f1 (0da89fac8e79)
[Subsystems] Discovering subsystems at path /Volumes/Samsung_T5/-/-/VK_PC/ooo.app/Contents/Resources/Data/UnitySubsystems
GfxDevice: creating device client; threaded=1; jobified=0
Color LCD preferred device: Intel Iris Pro Graphics (low power)
Metal devices available: 2
0: NVIDIA GeForce GT 750M (high power)
1: Intel Iris Pro Graphics (low power)
Using device NVIDIA GeForce GT 750M (high power)
Initializing Metal device caps: NVIDIA GeForce GT 750M
UnloadTime: 2.707413 ms
Deploy server command: ./undreamai_server -m "/Volumes/Samsung_T5/-/-/VK_PC/ooo.app/Contents/Resources/Data/StreamingAssets/AI_Models/Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf" -c 512 -b 2048 --log-disable -np 1 -ngl 0 --template "llama3 chat"
#0 GetStacktrace(int)
#1 DebugStringToFile(DebugStringToFileData const&)
#2 DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)
#3 DebugLogHandler_Internal_Log_m20852F18A88BB18425BA07260545E3968F7EA76C
#4 DebugLogHandler_LogFormat_m216B169EF9B669F2ED4C59F6B9F326D4EBBDF821
#5 InterfaceActionInvoker4<int, Object_tC12DECB6760A7F2CBF65D9DCF18D044C2D97152C*, String_t*, ObjectU5BU5D_t8061030B0A12A55D5AD8652A20C922FE99450918*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, int, Object_tC12DECB6760A7F2CBF65D9DCF18D044C2D97152C*, String_t*, ObjectU5BU5D_t8061030B0A12A55D5AD8652A20C922FE99450918*)
#6 Logger_Log_mEA3D39763D610E92491AA479BA653ECFEE3E9E5C
#7 InterfaceActionInvoker2<int, Il2CppObject*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, int, Il2CppObject*)
#8 Debug_Log_m87A9A3C761FF5C43ED8A53B16190A53D08F818BB
#9 LLMUnitySetup_Log_m32D48B75E9F1BDF490A447DD48FA74765BA54A20
#10 LLM_GetLlamaccpArguments_mBAA0A575110845D5AFD7568B285A6BC421B273CC
#11 VirtualFuncInvoker0<String_t*>::Invoke(unsigned short, Il2CppObject*)
#12 U3CAwakeU3Ed__55_MoveNext_m27E960B9D0F9ECA562E37BB8646470FB1378184A
#13 InterfaceActionInvoker0::Invoke(unsigned short, Il2CppClass*, Il2CppObject*)
#14 AsyncVoidMethodBuilder_Start_TisRuntimeObject_m3CA145CBB6CFE8B4ADD6148BF98E85899F95DCEA_gshared
#15 AsyncVoidMethodBuilder_Start_TisU3CAwakeU3Ed__55_t38EE5BB36239051FC430359AEC3FC1C46F6FF855_mCF7F81FD427485C1DBBE80344D41E8BBD6EB7011(AsyncVoidMethodBuilder_t253E37B63E7E7B504878AE6563347C147F98EF2D*, U3CAwakeU3Ed__55_t38EE5BB36239051FC430359AEC3FC1C46F6FF855**, MethodInfo const*)
#16 LLM_Awake_m51DDC60BEC88DE230414540A57C296C90B3A09B8
#17 RuntimeInvoker_TrueVoid_t4861ACF8F4594C3437BB48B6E56783494B843915(void ()(), MethodInfo const, void*, void**, void*)
#18 il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**)
#19 il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**)
#20 il2cpp_runtime_invoke
#21 scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)
#22 ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)
#23 ScriptingInvocation::InvokeChecked(ScriptingExceptionPtr*)
#24 SerializableManagedRef::CallMethod(Object&, ScriptingMethodPtr)
#25 MonoBehaviour::CallAwake()
#26 MonoBehaviour::AddToManager()
#27 MonoBehaviour::AwakeFromLoad(AwakeFromLoadMode)
#28 AwakeFromLoadQueue::InvokePersistentManagerAwake(AwakeFromLoadQueue::Item*, unsigned int, AwakeFromLoadMode, bool)
#29 AwakeFromLoadQueue::PersistentManagerAwakeFromLoad(ErrorsAndWarningsCapture*, bool)
#30 LoadSceneOperation::CompleteAwakeSequence()
#31 LoadSceneOperation::PlayerLoadSceneFromThread()
#32 LoadSceneOperation::CompleteLoadFirstScene()
#33 LoadSceneOperation::IntegrateMainThread()
#34 PreloadManager::UpdatePreloadingSingleStep(PreloadManager::UpdatePreloadingFlags, int)
#35 PreloadManager::WaitForAllAsyncOperationsToComplete()
#36 -[PlayerAppDelegate UpdatePlayer]
#37 -[PlayerAppDelegate TimerTick]
#38 __NSFireTimer
#39 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION
#40 __CFRunLoopDoTimer
#41 __CFRunLoopDoTimers
#42 __CFRunLoopRun
#43 CFRunLoopRunSpecific
#44 RunCurrentEventLoopInMode
#45 ReceiveNextEventCommon
#46 _BlockUntilNextEventMatchingListInModeWithFilter
#47 _DPSNextEvent
#48 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
#49 -[NSApplication run]
#50 NSApplicationMain
#51 PlayerMain(int, char const**)
#52 start

Tried architecture: x64-acc, System.Exception: Failed to load library x64-acc.
#0 GetStacktrace(int)
#1 DebugStringToFile(DebugStringToFileData const&)
#2 DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)
#3 DebugLogHandler_Internal_Log_m20852F18A88BB18425BA07260545E3968F7EA76C
#4 DebugLogHandler_LogFormat_m216B169EF9B669F2ED4C59F6B9F326D4EBBDF821
#5 InterfaceActionInvoker4<int, Object_tC12DECB6760A7F2CBF65D9DCF18D044C2D97152C*, String_t*, ObjectU5BU5D_t8061030B0A12A55D5AD8652A20C922FE99450918*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, int, Object_tC12DECB6760A7F2CBF65D9DCF18D044C2D97152C*, String_t*, ObjectU5BU5D_t8061030B0A12A55D5AD8652A20C922FE99450918*)
#6 Logger_Log_mEA3D39763D610E92491AA479BA653ECFEE3E9E5C
#7 InterfaceActionInvoker2<int, Il2CppObject*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, int, Il2CppObject*)
#8 Debug_Log_m87A9A3C761FF5C43ED8A53B16190A53D08F818BB
#9 LLMUnitySetup_Log_m32D48B75E9F1BDF490A447DD48FA74765BA54A20
#10 LLM_StartLLMServer_m7EC22542FA372186FDBECFE771C60CD8CCBBE8B9
#11 U3CU3Ec__DisplayClass55_0_U3CAwakeU3Eb__0_mEF8107541E2BA3BA472FF4ED5AA38A9A9ABBC622
#12 Task_InnerInvoke_m4FA9E513B4B539A5AC1C40D1EF4CA85544918366
#13 VirtualActionInvoker0::Invoke(unsigned short, Il2CppObject*)
#14 Task_Execute_m4FBCBCE932B924AD239A2448AED5708B6D14A7F1
#15 Task_ExecutionContextCallback_m72CB65AAA76D5FB962E36EC25AAC150A04EB47B3
#16 ContextCallback_Invoke_m872CCCD40428B88C2612772491BE5157895B5F61_OpenStatic(ContextCallback_tE8AFBDBFCC040FDA8DA8C1EEFE9BD66B16BDA007*, Il2CppObject*, MethodInfo const*)
#17 ExecutionContext_RunInternal_mC37E85D6FC972DF219A00FE1EE34329D1D63CC94
#18 ExecutionContext_Run_m6E5E07E0131DA97C6BC235754A0682CFFACE7BF8
#19 Task_ExecuteWithThreadLocal_mD3F4E7ADBBC473EAF7C24B3A785EBB452D6A76BE
#20 Task_ExecuteEntry_m735BD89474854D6EAA2ED929D6765AF1B4AEDCDF
#21 Task_System_Threading_IThreadPoolWorkItem_ExecuteWorkItem_mAEE759CC728F27B64F95C7B6C6E22FCD7E6F8801
#22 InterfaceActionInvoker0::Invoke(unsigned short, Il2CppClass*, Il2CppObject*)
#23 ThreadPoolWorkQueue_Dispatch_mEAAC936B3756DAA856BA3A4D976A98A3184CDC87
#24 _ThreadPoolWaitCallback_PerformWaitCallback_m6D08BAF0E0D909F86341B3EFBABCF294074C0B00
#25 RuntimeInvoker_FalseByte_t94D9231AC217BE4D2E004C4CD32DF6D099EA41A3(void ()(), MethodInfo const, void*, void**, void*)
#26 il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**)
#27 worker_thread(void*)
#28 il2cpp::vm::ThreadStart(void*)
#29 il2cpp::os::Thread::RunWrapper(void*)
#30 il2cpp::os::ThreadImpl::ThreadStartWrapper(void*)
#31 _pthread_start
#32 thread_start

Tried architecture: x64-no_acc, System.Exception: Failed to load library x64-no_acc.
#0 GetStacktrace(int)
#1 DebugStringToFile(DebugStringToFileData const&)
#2 DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)
#3 DebugLogHandler_Internal_Log_m20852F18A88BB18425BA07260545E3968F7EA76C
#4 DebugLogHandler_LogFormat_m216B169EF9B669F2ED4C59F6B9F326D4EBBDF821
#5 InterfaceActionInvoker4<int, Object_tC12DECB6760A7F2CBF65D9DCF18D044C2D97152C*, String_t*, ObjectU5BU5D_t8061030B0A12A55D5AD8652A20C922FE99450918*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, int, Object_tC12DECB6760A7F2CBF65D9DCF18D044C2D97152C*, String_t*, ObjectU5BU5D_t8061030B0A12A55D5AD8652A20C922FE99450918*)
#6 Logger_Log_mEA3D39763D610E92491AA479BA653ECFEE3E9E5C
#7 InterfaceActionInvoker2<int, Il2CppObject*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, int, Il2CppObject*)
#8 Debug_Log_m87A9A3C761FF5C43ED8A53B16190A53D08F818BB
#9 LLMUnitySetup_Log_m32D48B75E9F1BDF490A447DD48FA74765BA54A20
#10 LLM_StartLLMServer_m7EC22542FA372186FDBECFE771C60CD8CCBBE8B9
#11 U3CU3Ec__DisplayClass55_0_U3CAwakeU3Eb__0_mEF8107541E2BA3BA472FF4ED5AA38A9A9ABBC622
#12 Task_InnerInvoke_m4FA9E513B4B539A5AC1C40D1EF4CA85544918366
#13 VirtualActionInvoker0::Invoke(unsigned short, Il2CppObject*)
#14 Task_Execute_m4FBCBCE932B924AD239A2448AED5708B6D14A7F1
#15 Task_ExecutionContextCallback_m72CB65AAA76D5FB962E36EC25AAC150A04EB47B3
#16 ContextCallback_Invoke_m872CCCD40428B88C2612772491BE5157895B5F61_OpenStatic(ContextCallback_tE8AFBDBFCC040FDA8DA8C1EEFE9BD66B16BDA007*, Il2CppObject*, MethodInfo const*)
#17 ExecutionContext_RunInternal_mC37E85D6FC972DF219A00FE1EE34329D1D63CC94
#18 ExecutionContext_Run_m6E5E07E0131DA97C6BC235754A0682CFFACE7BF8
#19 Task_ExecuteWithThreadLocal_mD3F4E7ADBBC473EAF7C24B3A785EBB452D6A76BE
#20 Task_ExecuteEntry_m735BD89474854D6EAA2ED929D6765AF1B4AEDCDF
#21 Task_System_Threading_IThreadPoolWorkItem_ExecuteWorkItem_mAEE759CC728F27B64F95C7B6C6E22FCD7E6F8801
#22 InterfaceActionInvoker0::Invoke(unsigned short, Il2CppClass*, Il2CppObject*)
#23 ThreadPoolWorkQueue_Dispatch_mEAAC936B3756DAA856BA3A4D976A98A3184CDC87
#24 _ThreadPoolWaitCallback_PerformWaitCallback_m6D08BAF0E0D909F86341B3EFBABCF294074C0B00
#25 RuntimeInvoker_FalseByte_t94D9231AC217BE4D2E004C4CD32DF6D099EA41A3(void ()(), MethodInfo const, void*, void**, void*)
#26 il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**)
#27 worker_thread(void*)
#28 il2cpp::vm::ThreadStart(void*)
#29 il2cpp::os::Thread::RunWrapper(void*)
#30 il2cpp::os::ThreadImpl::ThreadStartWrapper(void*)
#31 _pthread_start
#32 thread_start

LLM service couldn't be created
#0 GetStacktrace(int)
#1 DebugStringToFile(DebugStringToFileData const&)
#2 DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)
#3 DebugLogHandler_Internal_Log_m20852F18A88BB18425BA07260545E3968F7EA76C
#4 DebugLogHandler_LogFormat_m216B169EF9B669F2ED4C59F6B9F326D4EBBDF821
#5 InterfaceActionInvoker4<int, Object_tC12DECB6760A7F2CBF65D9DCF18D044C2D97152C*, String_t*, ObjectU5BU5D_t8061030B0A12A55D5AD8652A20C922FE99450918*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, int, Object_tC12DECB6760A7F2CBF65D9DCF18D044C2D97152C*, String_t*, ObjectU5BU5D_t8061030B0A12A55D5AD8652A20C922FE99450918*)
#6 Logger_Log_mEA3D39763D610E92491AA479BA653ECFEE3E9E5C
#7 InterfaceActionInvoker2<int, Il2CppObject*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, int, Il2CppObject*)
#8 Debug_LogError_mB00B2B4468EF3CAF041B038D840820FB84C924B2
#9 LLMUnitySetup_LogError_m699765872C2C3A8B454FE2B909DAFC8A0ED2CAE3
#10 LLM_StartLLMServer_m7EC22542FA372186FDBECFE771C60CD8CCBBE8B9
#11 U3CU3Ec__DisplayClass55_0_U3CAwakeU3Eb__0_mEF8107541E2BA3BA472FF4ED5AA38A9A9ABBC622
#12 Task_InnerInvoke_m4FA9E513B4B539A5AC1C40D1EF4CA85544918366
#13 VirtualActionInvoker0::Invoke(unsigned short, Il2CppObject*)
#14 Task_Execute_m4FBCBCE932B924AD239A2448AED5708B6D14A7F1
#15 Task_ExecutionContextCallback_m72CB65AAA76D5FB962E36EC25AAC150A04EB47B3
#16 ContextCallback_Invoke_m872CCCD40428B88C2612772491BE5157895B5F61_OpenStatic(ContextCallback_tE8AFBDBFCC040FDA8DA8C1EEFE9BD66B16BDA007*, Il2CppObject*, MethodInfo const*)
#17 ExecutionContext_RunInternal_mC37E85D6FC972DF219A00FE1EE34329D1D63CC94
#18 ExecutionContext_Run_m6E5E07E0131DA97C6BC235754A0682CFFACE7BF8
#19 Task_ExecuteWithThreadLocal_mD3F4E7ADBBC473EAF7C24B3A785EBB452D6A76BE
#20 Task_ExecuteEntry_m735BD89474854D6EAA2ED929D6765AF1B4AEDCDF
#21 Task_System_Threading_IThreadPoolWorkItem_ExecuteWorkItem_mAEE759CC728F27B64F95C7B6C6E22FCD7E6F8801
#22 InterfaceActionInvoker0::Invoke(unsigned short, Il2CppClass*, Il2CppObject*)
#23 ThreadPoolWorkQueue_Dispatch_mEAAC936B3756DAA856BA3A4D976A98A3184CDC87
#24 _ThreadPoolWaitCallback_PerformWaitCallback_m6D08BAF0E0D909F86341B3EFBABCF294074C0B00
#25 RuntimeInvoker_FalseByte_t94D9231AC217BE4D2E004C4CD32DF6D099EA41A3(void ()(), MethodInfo const, void*, void**, void*)
#26 il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**)
#27 worker_thread(void*)
#28 il2cpp::vm::ThreadStart(void*)
#29 il2cpp::os::Thread::RunWrapper(void*)
#30 il2cpp::os::ThreadImpl::ThreadStartWrapper(void*)
#31 _pthread_start
#32 thread_start

LLM service couldn't be created
#0 GetStacktrace(int)
#1 DebugStringToFile(DebugStringToFileData const&)
#2 DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)
#3 DebugLogHandler_Internal_Log_m20852F18A88BB18425BA07260545E3968F7EA76C
#4 DebugLogHandler_LogFormat_m216B169EF9B669F2ED4C59F6B9F326D4EBBDF821
#5 InterfaceActionInvoker4<int, Object_tC12DECB6760A7F2CBF65D9DCF18D044C2D97152C*, String_t*, ObjectU5BU5D_t8061030B0A12A55D5AD8652A20C922FE99450918*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, int, Object_tC12DECB6760A7F2CBF65D9DCF18D044C2D97152C*, String_t*, ObjectU5BU5D_t8061030B0A12A55D5AD8652A20C922FE99450918*)
#6 Logger_Log_mEA3D39763D610E92491AA479BA653ECFEE3E9E5C
#7 InterfaceActionInvoker2<int, Il2CppObject*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, int, Il2CppObject*)
#8 Debug_LogError_mB00B2B4468EF3CAF041B038D840820FB84C924B2
#9 LLMUnitySetup_LogError_m699765872C2C3A8B454FE2B909DAFC8A0ED2CAE3
#10 LLM_AssertStarted_mAF658DF13FC239B2C0E190280AF793E56DDFF9E5
#11 U3CTokenizeU3Ed__96_MoveNext_m11D294F8ABBB33E41078DC407AC72D35AFAB50B1
#12 InterfaceActionInvoker0::Invoke(unsigned short, Il2CppClass*, Il2CppObject*)
#13 AsyncTaskMethodBuilder_1_Start_TisRuntimeObject_m4CC6B9A3F0DD032BDFC0B8416CE27980382ED173_gshared
#14 AsyncTaskMethodBuilder_1_Start_TisU3CTokenizeU3Ed__96_tB9A33EC8B491341F11815D12FB164C826BFFE3EB_m6E913221C7A88784DA8F0ED896F44C34609ED2B1(AsyncTaskMethodBuilder_1_tA28B0962049DC249BEC0054E2394B1962E28E90E*, U3CTokenizeU3Ed__96_tB9A33EC8B491341F11815D12FB164C826BFFE3EB**, MethodInfo const*)
#15 LLM_Tokenize_m06B188973886A3EAC73C42784FAA9F14362D0A34
#16 U3CPostRequestLocalU3Ed__29_2_MoveNext_mD1B6EE9A9D96635063445F4307C0E7C5F280FCAF_gshared
#17 InterfaceActionInvoker0::Invoke(unsigned short, Il2CppClass*, Il2CppObject*)
#18 MoveNextRunner_InvokeMoveNext_m4B7F4130C989B244668A0A57017A6C308E54D215
#19 ContextCallback_Invoke_m872CCCD40428B88C2612772491BE5157895B5F61_OpenStatic(ContextCallback_tE8AFBDBFCC040FDA8DA8C1EEFE9BD66B16BDA007*, Il2CppObject*, MethodInfo const*)
#20 ExecutionContext_RunInternal_mC37E85D6FC972DF219A00FE1EE34329D1D63CC94
#21 ExecutionContext_Run_m6E5E07E0131DA97C6BC235754A0682CFFACE7BF8
#22 MoveNextRunner_Run_m86395F123FB453F2B5FF89CE1E98532F7426F9DE
#23 YieldAwaiter_RunAction_mC611EE7A89483B65F4CA6D5362789551201309E0
#24 SendOrPostCallback_Invoke_m23B949AF9D78E8635F84E1E7775A50472B4F9C28_OpenStatic(SendOrPostCallback_t5C292A12062F24027A98492F52ECFE9802AA6F0E*, Il2CppObject*, MethodInfo const*)
#25 WorkRequest_Invoke_mBFEC6A3799BAFDE7ED840A0523D3D56160C03921
#26 UnitySynchronizationContext_Exec_m7E6352CBA70E4AB14F7D50A919C3F8C22F2E977A
#27 UnitySynchronizationContext_ExecuteTasks_m3034D59292339809C6D7FA5932ACC365892B8CA1
#28 RuntimeInvoker_FalseVoid_t4861ACF8F4594C3437BB48B6E56783494B843915(void ()(), MethodInfo const, void*, void**, void*)
#29 il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**)
#30 il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**)
#31 il2cpp_runtime_invoke
#32 scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)
#33 ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)
#34 Scripting::UnityEngine::UnitySynchronizationContextProxy::ExecuteTasks(ScriptingExceptionPtr*)
#35 InitPlayerLoopCallbacks()::UpdateScriptRunDelayedTasksRegistrator::Forward()
#36 ExecutePlayerLoop(NativePlayerLoopSystem*)
#37 ExecutePlayerLoop(NativePlayerLoopSystem*)
#38 PlayerLoop()
#39 -[PlayerAppDelegate UpdatePlayer]
#40 -[PlayerAppDelegate TimerTick]
#41 __NSFireTimer
#42 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION
#43 __CFRunLoopDoTimer
#44 __CFRunLoopDoTimers
#45 __CFRunLoopRun
#46 CFRunLoopRunSpecific
#47 RunCurrentEventLoopInMode
#48 ReceiveNextEventCommon
#49 _BlockUntilNextEventMatchingListInModeWithFilter
#50 _DPSNextEvent
#51 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
#52 -[NSApplication run]
#53 NSApplicationMain
#54 PlayerMain(int, char const**)
#55 start

@amakropoulos
Copy link
Collaborator

maybe with "/usr/lib/libc.dylib" as SystemLibrary?
Could you check if there are any dylib libraries in "/usr/lib/" with "system" or "System" and try those as well?

@CGAleksey
Copy link
Author

Maybe terminal output can help:
1)

testOS@Hello-PC ~ % otool -L /bin/ls | grep libSystem.B.dylib
2024-11-29 15:09:18.517 xcodebuild[1504:22317] [MT] PluginLoading: Required plug-in compatibility UUID 7A3A18B7-4C08-46F0-A96A-AB686D315DF0 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Unity4XC.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2024-11-29 15:09:18.519 xcodebuild[1504:22317] Failed to load plugin at: /Users/Alexey/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Unity4XC.xcplugin, skipping. Reason for failure: *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.120.1)

testOS@Hello-PC ~ % otool -L /bin/ls | grep libSystem.dylib
testOS@Hello-PC ~ %

Could you check if there are any dylib libraries in "/usr/lib/" with "system" or "System" and try those as well?
There are no files with a "system" or "System" in the name.

testOS@Hello-PC ~ % ls /usr/lib
charset.alias libpython2.7.dylib
cron libstdc++.6.dylib
dsc_extractor.bundle libstdc++.dylib
dtrace log
dyld pam
groff php
libLeaksAtExit.dylib pkgconfig
libMTLCapture.dylib python2.7
libffi-trampolines.dylib rpcsvc
libgmalloc.dylib ruby
libhunspell-1.2.0.dylib sasl2
libhunspell-1.2.dylib sqlite3
libiodbc.2.dylib ssh-keychain.dylib
libiodbc.dylib swift
libiodbcinst.2.dylib system
libiodbcinst.dylib updaters
libobjc-trampolines.dylib xpc
libpython.dylib zsh

tried private const string SystemLibrary = "/usr/lib/libc.dylib";// "libSystem.B.dylib";
Result: there is nothing in console, dialog prompt does not appear

@CGAleksey
Copy link
Author

Also I tried:

testOS@Hello-PC ~ % ls -la /usr/lib/libSystem.B.dylib
ls: /usr/lib/libSystem.B.dylib: No such file or directory

testOS@Hello-PC ~ % ls -la /usr/lib/libSystem.dylib
ls: /usr/lib/libSystem.dylib: No such file or directory

testOS@Hello-PC ~ % otool -L /usr/lib/libSystem.B.dylib
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool-classic: can't open file: /usr/lib/libSystem.B.dylib (No such file or directory)

testOS@Hello-PC ~ % otool -L /usr/lib/libSystem.dylib
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool-classic: can't open file: /usr/lib/libSystem.dylib (No such file or directory)


testOS@Hello-PC ~ % ls -la /usr/lib/system
total 1632
drwxr-xr-x 7 root wheel 224 Jan 1 2020 .
drwxr-xr-x 38 root wheel 1216 Jan 1 2020 ..
drwxr-xr-x 4 root wheel 128 Jan 1 2020 introspection
-rwxr-xr-x 1 root wheel 1490032 Jan 1 2020 libsystem_kernel.dylib
-rwxr-xr-x 1 root wheel 432896 Jan 1 2020 libsystem_platform.dylib
-rwxr-xr-x 1 root wheel 576816 Jan 1 2020 libsystem_pthread.dylib
-rwxr-xr-x 1 root wheel 120608 Jan 1 2020 wordexp-helper

testOS@Hello-PC ~ % find /usr/lib/ -iname "system"
/usr/lib//system
/usr/lib//system/libsystem_pthread.dylib
/usr/lib//system/introspection/libsystem_pthread.dylib
/usr/lib//system/libsystem_kernel.dylib
/usr/lib//system/libsystem_platform.dylib
/usr/lib//zsh/5.8/zsh/system.so

tried these options:
private const string SystemLibrary = "/usr/lib/system/libsystem_kernel.dylib";
Result: there is nothing in console, dialog prompt does not appear

private const string SystemLibrary = "/usr/lib/system/libsystem_platform.dylib";
Result: there is nothing in console, dialog prompt does not appear

private const string SystemLibrary = "/usr/lib/system/libsystem_pthread.dylib";
Result: there is nothing in console, dialog prompt does not appear

private const string SystemLibrary = "/usr/lib/system/libsystem_pthread.dylib";
Result: there is nothing in console, dialog prompt does not appear

private const string SystemLibrary = "/usr/lib//zsh/5.8/zsh/system.so";
Result: there is nothing in console, dialog prompt does not appear

I think the “libSystem.B.dylib” library exists, but for some reason it is not visible to me. I don't know why.

@amakropoulos
Copy link
Collaborator

maybe just with "libdl"?
private const string SystemLibrary = "libdl";

@CGAleksey
Copy link
Author

CGAleksey commented Dec 2, 2024

maybe just with "libdl"?
private const string SystemLibrary = "libdl";

Doesn't work.

Is it possible to get the progress of the LLM's state of readiness to work?
Maybe on a mac the initialization takes a long time and I can't wait. The same computer has Windows installed on it and everything works.

For tests I use LLMCharacter.cs, the program freezes at the line with "if(!await InitNKeep())"

        public virtual async Task Warmup(EmptyCallback completionCallback = null)
        {
            await LoadTemplate();
            if (!CheckTemplate()) return;
            if (!await InitNKeep()) return;// STUCK HERE

            string prompt = template.ComputePrompt(chat, playerName, AIName);
            ChatRequest request = GenerateRequest(prompt);
            request.n_predict = 0;
            string json = JsonUtility.ToJson(request);
            await CompletionRequest(json);
            completionCallback?.Invoke();
        }

@amakropoulos
Copy link
Collaborator

maybe something else is off if the LoadTemplate before works.
are you running a sample e.g. SimpleInteraction?
Let me know if you'd like to have a call to have a look at it

@CGAleksey
Copy link
Author

I ran it, but I think the problem is in the libraries. I tried many things, it doesn't help.
Thanks, I'll email you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants