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

NuGet package with binary deps for linux x64 #25

Closed
lejsekt opened this issue Oct 7, 2022 · 9 comments
Closed

NuGet package with binary deps for linux x64 #25

lejsekt opened this issue Oct 7, 2022 · 9 comments

Comments

@lejsekt
Copy link

lejsekt commented Oct 7, 2022

Hey,
I haven't found a NuGet package containing the binary dependencies for linux x64 platform. I've created one (based on the provided Dockerfile) for internal use as the provided docker images are sufficient for deployment, but not development scenarios. I'm now dockerizing the build of the package. Would you be interested in a PR? What are you thoughts on this?

@sdcb
Copy link
Owner

sdcb commented Oct 8, 2022

Hi
I tried but it seems very hard to make it working on a raw linux environment without further package-installation.
I'm happy to see you can make it work and I'm open to any PR, but I have to confirm how you made it and is it really works :)

@lejsekt
Copy link
Author

lejsekt commented Oct 11, 2022

It's working for me in Ubuntu Focal and Ubuntu Jammy docker container. It's just taking the binaries used to produce the docker images to produce a NuGet package instead.

Dockerfile:

FROM mcr.microsoft.com/dotnet/sdk:6.0-focal as builder

WORKDIR /

RUN apt-get update && apt-get -y install --no-install-recommends \
    wget \
    && apt-get -y clean \
    && rm -rf /var/lib/apt/lists/*

RUN wget -q https://paddle-inference-lib.bj.bcebos.com/2.3.2/cxx_c/Linux/CPU/gcc8.2_avx_mkl/paddle_inference_c.tgz

RUN tar -xzf /paddle_inference_c.tgz && \
    mkdir -p /build/lib && \
    find /paddle_inference_c -mindepth 2 -name *.so* -print0 | xargs -0 -I {} mv {} /build/lib && \
    ls /usr/lib/*.so* && \
    rm -rf /paddle_inference_c && \
    rm paddle_inference_c.tgz

WORKDIR /build

COPY PaddleInference.runtime.linux-x64.csproj .

RUN dotnet pack -c Release -o package

FROM scratch

COPY --from=builder /build/package .

PaddleInference.runtime.linux-x64.csproj:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <VersionPrefix>0.1.0</VersionPrefix>
        <VersionSuffix>SNAPSHOT</VersionSuffix>
        <TargetFramework>netstandard2.0</TargetFramework>       
        <Description>Linux native dependecies for Paddle</Description>        
        <NoBuild>true</NoBuild>
        <IncludeBuildOutput>false</IncludeBuildOutput>
    </PropertyGroup>

    <ItemGroup>
        <Content Include="lib/**" PackagePath="runtimes/linux-x64/native" Visible="false" />
    </ItemGroup>
</Project>

And then build it with: docker buildx build . -o export

And when one uses the package, it's necessary to add runtimes/linux-x64/native dir to LD_LIBRARY_PATH.

@sdcb
Copy link
Owner

sdcb commented Oct 13, 2022

Actually in my build-native.linq script it can generate the linux nuget package automatically.
I believe this only contains paddle inference reference, however it is very likely not working when installed in a raw linux machine without install other dependencies(likely specific version of GCC etc.), still need couples of debugging with ldd

@lejsekt
Copy link
Author

lejsekt commented Oct 21, 2022

In my opinion, it's not necessary to support a raw linux machine with the nuget package. But it should enable developers on linux to use the library more easily. Otherwise, it's necessary to somehow setup a docker environment for development.

If there's a script to produce the package already, that's great. Do you think you could publish that package as part of the release procedure? In a similar manner as the windows one.

@sdcb
Copy link
Owner

sdcb commented Oct 26, 2022

Yes I can publish the Linux nuget package, however I believe a lots of client will be very hard to understand a nuget package isn't enough to run LOL, they will very likely choose docker to run in Linux.
However if I not publish, they will surely ask LOL~

@sdcb
Copy link
Owner

sdcb commented Oct 26, 2022

@lejsekt please checkout the nuget package and have a test, please tell me if there is any question:
https://www.nuget.org/packages/Sdcb.PaddleInference.runtime.linux64.mkl.gcc82/2.3.2-preview.1

Please note that linux is linking some dynamic libraries with symlinks, however it's does not supported in NuGet, so I made a few copies(which isn't very efficient): NuGet/Home#10734

@lejsekt
Copy link
Author

lejsekt commented Nov 1, 2022

Thanks, I'll give it a try.

@lejsekt
Copy link
Author

lejsekt commented Nov 2, 2022

Works as expected, thanks. Looking forward to a release version of the package.

@sdcb
Copy link
Owner

sdcb commented Dec 7, 2022

Works as expected, thanks. Looking forward to a release version of the package.

I think I shouldn't make a release version because it seems not make sense by hard copy these linked .so files.

@sdcb sdcb closed this as completed Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants