Skip to content

[Build] [Linux] [.NET] Microsoft.ML.OnnxRuntime.Gpu keep publishing unnecessary DLL large files for linux-x64 #23077

@jiaxuwu2021

Description

@jiaxuwu2021

Describe the issue

Nuget package Microsoft.ML.OnnxRuntime.Gpu 1.20.1 keep publishing DLL files for linux-x64, especially onnxruntime_providers_cuda.dll which is very large (>600MB), these DLL files are unnecessary to linux
Image
Please fix to stop publishing these onnxruntime*.dll files for linux-x64 when dotnet build/dotnet publish, otherwise the final binaries size will be double (both cuda.so and cuda.dll >600MB)


One possible clue: it seems that this file Microsoft.ML.OnnxRuntime.Gpu.Windows.props is trying to copy DLL files for all x64 platforms including linux-x64.
Image

Related issue: microsoft/onnxruntime-genai#1135

Urgency

No response

Target platform

linux-x64

Build script

build linux-x64 under linux command line:
dotnet publish test.csproj --runtime linux-x64

  • test.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <PublishAot>true</PublishAot>
    <IsPackable>false</IsPackable>
    <SelfContained>true</SelfContained>
  </PropertyGroup>

  <!-- OnnxRuntime CUDA https://onnxruntime.ai/docs/get-started/with-csharp.html#builds -->
  <ItemGroup>
    <PackageReference Include="Microsoft.ML.OnnxRuntime.Gpu" Version="1.20.1" />
  </ItemGroup>
</Project>
  • Program.cs
namespace MyTest;

using Microsoft.ML.OnnxRuntime;

public class Program
{
    public static async Task Main(string[] args)
    {
        const string modelPath = "/home/jiaxuwu/.aitk/models/onnx/cuda/mistral-7b-instruct-v0.2-cuda-int4-rtn-block-32/mistral-7b-instruct-v0.2-cuda-int4-rtn-block-32.onnx";
        using var session = new InferenceSession(modelPath);
    }
}

Error / output

There are many DLL files in the final binaries

$ ll -h bin/Release/net8/linux-x64/publish/onnxruntime*.dll
...  12M Nov 19 23:09 bin/Release/net8/linux-x64/publish/onnxruntime.dll*
... 643M Nov 19 23:10 bin/Release/net8/linux-x64/publish/onnxruntime_providers_cuda.dll*
...  22K Nov 19 23:10 bin/Release/net8/linux-x64/publish/onnxruntime_providers_shared.dll*
... 744K Nov 19 23:09 bin/Release/net8/linux-x64/publish/onnxruntime_providers_tensorrt.dll*
$ ll -h bin/Release/net8/linux-x64/onnxruntime*.dll
...  12M Nov 19 23:09 bin/Release/net8/linux-x64/onnxruntime.dll*
... 643M Nov 19 23:10 bin/Release/net8/linux-x64/onnxruntime_providers_cuda.dll*
...  22K Nov 19 23:10 bin/Release/net8/linux-x64/onnxruntime_providers_shared.dll*
... 744K Nov 19 23:09 bin/Release/net8/linux-x64/onnxruntime_providers_tensorrt.dll*

Visual Studio Version

No response

GCC / Compiler Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .net codeapi:CSharpissues related to the C# APIbuildbuild issues; typically submitted using templateep:CUDAissues related to the CUDA execution providerstaleissues that have not been addressed in a while; categorized by a bot

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions