Mac build doesn't copy over .gguf file and llm does not work in Mac build
Describe the bug
When building for Mac- the llm does not work in the build as the .gguf file is not copied into the build- the StreamingAssets folder is not even created in the Mac build- LLm in the Windows build works perfectly though.
I tried manually creating and the StreamingAssets folder + gguf file into the Mac build .app but the llm still does not work in game.
This error is thrown during the Mac build process but the build succeeds(doesn't work though)
UnauthorizedAccessException: Access to the path 'undreamai_windows-cuda-cu12.2.0.dll' is denied. System.IO.FileSystem.RemoveDirectoryRecursive (System.String fullPath, Interop+Kernel32+WIN32_FIND_DATA& findData, System.Boolean topLevel) (at <1071a2cb0cb3433aae80a793c277a048>:0) System.IO.FileSystem.RemoveDirectory (System.String fullPath, System.Boolean recursive) (at <1071a2cb0cb3433aae80a793c277a048>:0) System.IO.Directory.Delete (System.String path, System.Boolean recursive) (at <1071a2cb0cb3433aae80a793c277a048>:0) LLMUnity.LLMBuilder.DeletePath (System.String path) (at ./Library/PackageCache/ai.undream.llm@891497bf8a/Runtime/LLMBuilder.cs:110) LLMUnity.LLMBuilder.MovePath (System.String source, System.String target) (at ./Library/PackageCache/ai.undream.llm@891497bf8a/Runtime/LLMBuilder.cs:92) LLMUnity.LLMBuilder.MoveAction (System.String source, System.String target, System.Boolean addEntry) (at ./Library/PackageCache/ai.undream.llm@891497bf8a/Runtime/LLMBuilder.cs:133) LLMUnity.LLMBuilder.BuildLibraryPlatforms (UnityEditor.BuildTarget buildTarget) (at ./Library/PackageCache/ai.undream.llm@891497bf8a/Runtime/LLMBuilder.cs:200) LLMUnity.LLMBuilder.Build (UnityEditor.BuildTarget buildTarget) (at ./Library/PackageCache/ai.undream.llm@891497bf8a/Runtime/LLMBuilder.cs:253) LLMUnity.LLMBuildProcessor.OnPreprocessBuild (UnityEditor.Build.Reporting.BuildReport report) (at ./Library/PackageCache/ai.undream.llm@891497bf8a/Editor/LLMBuildProcessor.cs:20) UnityEditor.Build.BuildPipelineInterfaces+<>c__DisplayClass16_0.<OnBuildPreProcess>b__1 (UnityEditor.Build.IPreprocessBuildWithReport bpp) (at <4b8f645257c94d1296f440a10c6f388e>:0) UnityEditor.Build.BuildPipelineInterfaces.InvokeCallbackInterfacesPair[T1,T2] (System.Collections.Generic.Lis1[T] oneInterfaces, System.Action1[T] invocationOne, System.Collections.Generic.Lis1[T] twoInterfaces, System.Action1[T] invocationTwo, System.Boolean exitOnFailure) (at <4b8f645257c94d1296f440a10c6f388e>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) IOException: The file exists System.IO.FileSystem.MoveFile (System.String sourceFullPath, System.String destFullPath) (at <1071a2cb0cb3433aae80a793c277a048>:0) System.IO.File.Move (System.String sourceFileName, System.String destFileName) (at <1071a2cb0cb3433aae80a793c277a048>:0) LLMUnity.LLMBuilder.HandleActionFileRecursive (System.String source, System.String target, LLMUnity.ActionCallback actionCallback) (at ./Library/PackageCache/ai.undream.llm@891497bf8a/Runtime/LLMBuilder.cs:49) LLMUnity.LLMBuilder.HandleActionFileRecursive (System.String source, System.String target, LLMUnity.ActionCallback actionCallback) (at ./Library/PackageCache/ai.undream.llm@891497bf8a/Runtime/LLMBuilder.cs:59) LLMUnity.LLMBuilder.MovePath (System.String source, System.String target) (at ./Library/PackageCache/ai.undream.llm@891497bf8a/Runtime/LLMBuilder.cs:91) LLMUnity.LLMBuilder.MoveAction (System.String source, System.String target, System.Boolean addEntry) (at ./Library/PackageCache/ai.undream.llm@891497bf8a/Runtime/LLMBuilder.cs:133) LLMUnity.LLMBuilder.Reset () (at ./Library/PackageCache/ai.undream.llm@891497bf8a/Runtime/LLMBuilder.cs:270) LLMUnity.LLMBuildProcessor.<BuildCompleted>b__5_0 () (at ./Library/PackageCache/ai.undream.llm@891497bf8a/Editor/LLMBuildProcessor.cs:94) UnityEditor.EditorApplication.Internal_CallDelayFunctions () (at <4b8f645257c94d1296f440a10c6f388e>:0)
Steps to reproduce
Try to build a Unity game for Mac(apple Silicon) that includes a gguf file- the llm will not work in game and the gguf file is not included in the build.
LLMUnity version
2.5.2
Operating System
Windows
I removed all the Windows and Linux related folders from the StreamingAssets folder in the Unity project and the Mac build was completed without errors but the llm functionality still does not work in the Mac build-
I'm running a dev build for Mac OS and when trying to use the LLM no errors are thrown, its just that nothing happens. Works perfectly in Editor on Windows and in Windows builds.
Has anyone gotten a Mac build with LLMUnity working in it? If so how?
I copied the Unity project folder over to my Apple Silicon machine to test LLMUnity in the Editor on a Mac-
If I try to use LLMUnity on the Mac Editor it doesn't work and I get this error-
LLM service couldn't be created UnityEngine.Debug:LogError (object) LLMUnity.LLMUnitySetup:LogError (string) (at Assets/LLMUnity/Runtime/LLMUnitySetup.cs:200) LLMUnity.LLM:AssertStarted () (at Assets/LLMUnity/Runtime/LLM.cs:616) LLMUnity.LLM/<Tokenize>d__97:MoveNext () (at Assets/LLMUnity/Runtime/LLM.cs:679) System.Runtime.CompilerServices.AsyncTaskMethodBuilder12<LLMUnity.TokenizeResult, System.Collections.Generic.List11<System.Collections.Generic.List12<LLMUnity.TokenizeResult, System.Collections.Generic.List12<LLMUnity.TokenizeResult, System.Collections.Generic.List11<int>> (string,string,LLMUnity.ContentCallback2<LLMUnity.TokenizeResult, System.Collections.Generic.List1<int>>,LLMUnity.Callback1<System.Collections.Generic.List1<int>>) LLMUnity.LLMCharacter:<>n__0<LLMUnity.TokenizeResult, System.Collections.Generic.List12<LLMUnity.TokenizeResult, System.Collections.Generic.List11<System.Collections.Generic.List12<LLMUnity.TokenizeResult, System.Collections.Generic.List11<System.Collections.Generic.List12<LLMUnity.TokenizeResult, System.Collections.Generic.List12<LLMUnity.TokenizeResult, System.Collections.Generic.List11<int>> (string,string,LLMUnity.ContentCallback2<LLMUnity.TokenizeResult, System.Collections.Generic.List1<int>>,LLMUnity.Callback1<System.Collections.Generic.List1<int>>) LLMUnity.LLMCaller/<PostRequest>d__312<LLMUnity.TokenizeResult, System.Collections.Generic.List1<int>>:MoveNext () (at Assets/LLMUnity/Runtime/LLMCaller.cs:339) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1<System.Collections.Generic.List1<int>>:Start<LLMUnity.LLMCaller/<PostRequest>d__312<LLMUnity.TokenizeResult, System.Collections.Generic.List1<int>>> (LLMUnity.LLMCaller/<PostRequest>d__312<LLMUnity.TokenizeResult, System.Collections.Generic.List1<int>>&) LLMUnity.LLMCaller:PostRequest<LLMUnity.TokenizeResult, System.Collections.Generic.List12<LLMUnity.TokenizeResult, System.Collections.Generic.List11<System.Collections.Generic.List11<System.Collections.Generic.List11<System.Collections.Generic.List11<bool>:Start<LLMUnity.LLMCharacter/<InitNKeep>d__51> (LLMUnity.LLMCharacter/<InitNKeep>d__51&) LLMUnity.LLMCharacter:InitNKeep () LLMUnity.LLMCharacter/<Chat>d__70:MoveNext () (at Assets/LLMUnity/Runtime/LLMCharacter.cs:526) System.Runtime.CompilerServices.AsyncTaskMethodBuilder11<string>,LLMUnity.EmptyCallback,bool) SimpleLLMChat/<SendMessageAsync>d__4:MoveNext () (at Assets/Scripts/SimpleLLMChat.cs:29) System.Runtime.CompilerServices.AsyncTaskMethodBuilder11<single>,MEC.Segment,int,bool,string,MEC.CoroutineHandle,bool) (at Assets/Plugins/Trinary Software/Timing.cs:2345) MEC.Timing:RunCoroutine (System.Collections.Generic.IEnumerator1
Exception: LLM service couldn't be created
LLMUnity.LLM.AssertStarted () (at Assets/LLMUnity/Runtime/LLM.cs:617)
LLMUnity.LLM.Tokenize (System.String json) (at Assets/LLMUnity/Runtime/LLM.cs:679)
LLMUnity.LLMCaller.PostRequestLocal[Res,Ret] (System.String json, System.String endpoint, LLMUnity.ContentCallback2[T,T2] getContent, LLMUnity.Callback1[T] callback) (at Assets/LLMUnity/Runtime/LLMCaller.cs:245)
LLMUnity.LLMCharacter.PostRequestLocal[Res,Ret] (System.String json, System.String endpoint, LLMUnity.ContentCallback2[T,T2] getContent, LLMUnity.Callback1[T] callback) (at Assets/LLMUnity/Runtime/LLMCharacter.cs:685)
LLMUnity.LLMCaller.PostRequest[Res,Ret] (System.String json, System.String endpoint, LLMUnity.ContentCallback2[T,T2] getContent, LLMUnity.Callback1[T] callback) (at Assets/LLMUnity/Runtime/LLMCaller.cs:339)
LLMUnity.LLMCaller.Tokenize (System.String query, LLMUnity.Callback1[T] callback) (at Assets/LLMUnity/Runtime/LLMCaller.cs:354) LLMUnity.LLMCharacter.InitNKeep () (at Assets/LLMUnity/Runtime/LLMCharacter.cs:269) LLMUnity.LLMCharacter.Chat (System.String query, LLMUnity.Callback1[T] callback, LLMUnity.EmptyCallback completionCallback, System.Boolean addToHistory) (at Assets/LLMUnity/Runtime/LLMCharacter.cs:526)
SimpleLLMChat.SendMessageAsync (System.String message, System.Boolean addToHistory) (at Assets/Scripts/SimpleLLMChat.cs:29)
Rethrow as AggregateException: One or more errors occurred. (LLM service couldn't be created)
System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) (at 1[TResult].GetResultCore (System.Boolean waitCompletionNotification) (at <cac1dea318b4499fb9eaf77618617c23>:0) System.Threading.Tasks.Task1[TResult].get_Result () (at 1[T] coroutine, MEC.Segment segment, System.Int32 layer, System.Boolean layerHasValue, System.String tag, MEC.CoroutineHandle handle, System.Boolean prewarm) (at Assets/Plugins/Trinary Software/Timing.cs:2345) UnityEngine.Debug:LogException(Exception) MEC.Timing:RunCoroutineInternal(IEnumerator1, Segment, Int32, Boolean, String, CoroutineHandle, Boolean) (at Assets/Plugins/Trinary Software/Timing.cs:2757)
MEC.Timing:RunCoroutine(IEnumerator`1) (at Assets/Plugins/Trinary Software/Timing.cs:1189)
RoomControls:DrobotBark() (at Assets/Scripts/RoomControls.cs:778)
`
I got LLMUnity to work properly in the Editor on Mac- I just had to manually reload the gguf file. I was also able to get the Mac build working by building it from the Mac version of the Editor.
LLMUnity is about 10x slower on my Apple Silicon machine that it is on my Windows PC so now I need to figure out how to optimize/speed it up on Apple Silicon.
thanks for the debugging. probably the gguf file was moved and the project couldn't find it anymore for some reason. Maybe you use GPU on the Windows PC while on Mac only CPU?