Thread group count limit - error when running mobilesam

Using this model from here for example.

When running with a GPUCompute backend I get a warning and then an error:

Warning: Exceeded safe compute dispatch group count limit per dimension [1, 65536, 1] for Transpose2D
Error: Thread group count is above the maximum allowed limit. Maximum allowed thread group count is 65535.
Full Log
Exceeded safe compute dispatch group count limit per dimension [1, 65536, 1] for Transpose2D
UnityEngine.Debug:LogWarning (object)
Unity.Sentis.D:LogWarning (object) (at ./Library/PackageCache/com.unity.sentis@1.3.0-pre.1/Runtime/Core/Internals/Debug.cs:72)
Unity.Sentis.ComputeHelper:Dispatch (Unity.Sentis.ComputeFunc,int,int,int) (at ./Library/PackageCache/com.unity.sentis@1.3.0-pre.1/Runtime/Core/Backends/GPUCompute/ComputeHelper.cs:193)
Unity.Sentis.GPUComputeBackend:Transpose (Unity.Sentis.Tensor,Unity.Sentis.Tensor,int[]) (at ./Library/PackageCache/com.unity.sentis@1.3.0-pre.1/Runtime/Core/Backends/GPUCompute/GPUCompute.cs:1902)
Unity.Sentis.Layers.Transpose:Execute (Unity.Sentis.Tensor[],Unity.Sentis.ExecutionContext) (at ./Library/PackageCache/com.unity.sentis@1.3.0-pre.1/Runtime/Core/Layers/Layer.Transformation.cs:1365)
Unity.Sentis.GenericWorker/<StartManualSchedule>d__33:MoveNext () (at ./Library/PackageCache/com.unity.sentis@1.3.0-pre.1/Runtime/Core/Backends/GenericWorker.cs:243)
Unity.Sentis.GenericWorker:Execute () (at ./Library/PackageCache/com.unity.sentis@1.3.0-pre.1/Runtime/Core/Backends/GenericWorker.cs:176)
Unity.Sentis.GenericWorker:Execute (Unity.Sentis.Tensor) (at ./Library/PackageCache/com.unity.sentis@1.3.0-pre.1/Runtime/Core/Backends/GenericWorker.cs:168)
MobileSAM.MobileSAMPredictor:Encode (UnityEngine.Texture) (at ./Packages/com.doji.mobilesam/Runtime/Scripts/MobileSAMPredictor.cs:99)
MyProject.Test:Update () (at Assets/Test.cs:24)
Thread group count is above the maximum allowed limit. Maximum allowed thread group count is 65535.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Unity.Sentis.ComputeHelper:Dispatch (Unity.Sentis.ComputeFunc,int,int,int) (at ./Library/PackageCache/com.unity.sentis@1.3.0-pre.1/Runtime/Core/Backends/GPUCompute/ComputeHelper.cs:195)
Unity.Sentis.GPUComputeBackend:Transpose (Unity.Sentis.Tensor,Unity.Sentis.Tensor,int[]) (at ./Library/PackageCache/com.unity.sentis@1.3.0-pre.1/Runtime/Core/Backends/GPUCompute/GPUCompute.cs:1902)
Unity.Sentis.Layers.Transpose:Execute (Unity.Sentis.Tensor[],Unity.Sentis.ExecutionContext) (at ./Library/PackageCache/com.unity.sentis@1.3.0-pre.1/Runtime/Core/Layers/Layer.Transformation.cs:1365)
Unity.Sentis.GenericWorker/<StartManualSchedule>d__33:MoveNext () (at ./Library/PackageCache/com.unity.sentis@1.3.0-pre.1/Runtime/Core/Backends/GenericWorker.cs:243)
Unity.Sentis.GenericWorker:Execute () (at ./Library/PackageCache/com.unity.sentis@1.3.0-pre.1/Runtime/Core/Backends/GenericWorker.cs:176)
Unity.Sentis.GenericWorker:Execute (Unity.Sentis.Tensor) (at ./Library/PackageCache/com.unity.sentis@1.3.0-pre.1/Runtime/Core/Backends/GenericWorker.cs:168)
MobileSAM.MobileSAMPredictor:Encode (UnityEngine.Texture) (at ./Packages/com.doji.mobilesam/Runtime/Scripts/MobileSAMPredictor.cs:99)
MyProject.Test:Update () (at Assets/Test.cs:24)
1 Like

Thanks, with which input image dimension?
We’ll fix it, big input tensor is busting the dispatch limit.

2 Likes

Smallest resolution I found that reproduces this is a 1024x1024 image ((1024, 1024, 3) Tensor)

Ok thanks, I’d lower the resolution count for now before we patch it

1 Like

This is known internally as Task 204

1 Like