Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
"Bash(WHISPER_MODEL_PATH=/home/brandon/openvino.genai/ov_cache0/test_models/WhisperTiny/openai/whisper-tiny LD_LIBRARY_PATH=/home/brandon/openvino.genai/build/openvino_genai:/home/brandon/openvino.genai/.venv/lib/python3.12/site-packages/openvino/libs dotnet run --project samples/WhisperDemo -- /home/brandon/openvino.genai/ov_cache0/test_models/WhisperTiny/openai/whisper-tiny /home/brandon/openvino.genai/ov_cache0/test_data/how_are_you_doing_today.wav)",
"Bash(Remove-Item -Path \"samples\\WhisperDemo\\bin\\Debug\\net8.0\\runtimes\\win-x64\\native\\*.dll\" -Force)",
"Bash(C:UsersbrandDocumentsIntelOpenVINOopenvino_c_samples_buildintel64Releasewhisper_speech_recognition_c.exe \"C:\\Users\\brand\\code\\OpenVINO.GenAI.NET\\Models\\whisper-tiny-int4-ov-npu\" \"C:\\Users\\brand\\code\\OpenVINO.GenAI.NET\\how_are_you_doing_today.wav\" NPU)",
"Bash(.whisper_speech_recognition_c.exe:*)"
"Bash(.whisper_speech_recognition_c.exe:*)",
"Bash(Remove-Item -Path \"temp_package.zip\", \"temp_package_extract\" -Recurse -Force)",
"Bash(cmd /c:*)"
],
"deny": []
}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ dotnet run --project samples/QuickDemo -- --benchmark

## Troubleshooting

For detailed NuGet package troubleshooting, see [NuGet Troubleshooting Guide](docs/NUGET_TROUBLESHOOTING.md).

### Common Issues

#### 1. "OpenVINO runtime not found"
Expand Down
202 changes: 202 additions & 0 deletions docs/NUGET_TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
# NuGet Package Troubleshooting Guide

## Overview

The `Fluid.OpenVINO.GenAI` NuGet package includes both managed assemblies and native OpenVINO libraries. This guide helps troubleshoot common issues with the package.

## Package Structure

When installed, the package contains:
- **Managed Assembly**: `lib/net8.0/OpenVINO.NET.GenAI.dll`
- **Native Libraries**: `runtimes/[win-x64|linux-x64]/native/*.dll` or `*.so`
- **MSBuild Targets**: `build/Fluid.OpenVINO.GenAI.targets`

## Common Issues and Solutions

### Issue 1: Native Libraries Not Found

**Symptoms:**
- Build warnings about missing OpenVINO GenAI native libraries
- Runtime errors when trying to use LLMPipeline or WhisperPipeline
- `DllNotFoundException` or similar errors

**Solutions:**

1. **Verify Package Installation**
```bash
dotnet list package
```
Ensure `Fluid.OpenVINO.GenAI` is listed with the correct version.

2. **Check NuGet Cache**
The package should be in:
- Windows: `%USERPROFILE%\.nuget\packages\fluid.openvino.genai\[version]\`
- Linux: `~/.nuget/packages/fluid.openvino.genai/[version]/`

3. **Verify Native Libraries Exist**
Check for native libraries in the package:
```powershell
# Windows
dir "%USERPROFILE%\.nuget\packages\fluid.openvino.genai\2025.3.0-dev20250801\runtimes\win-x64\native"

# Linux
ls ~/.nuget/packages/fluid.openvino.genai/2025.3.0-dev20250801/runtimes/linux-x64/native
```

4. **Force Package Reinstallation**
```bash
dotnet nuget locals all --clear
dotnet restore --force
```

### Issue 2: Libraries Not Copied to Output

**Symptoms:**
- Build succeeds but native DLLs are not in the output directory
- Application fails at runtime with missing DLL errors

**Solutions:**

1. **Check MSBuild Targets Execution**
Build with diagnostic verbosity:
```bash
dotnet build -v d | Select-String "OpenVINO"
```

2. **Set Environment Variable**
If automatic discovery fails, set the `OPENVINO_RUNTIME_PATH`:
```powershell
# Windows
$env:OPENVINO_RUNTIME_PATH = "C:\path\to\openvino\runtime"

# Linux
export OPENVINO_RUNTIME_PATH="/path/to/openvino/runtime"
```

3. **Manual Copy as Workaround**
Add to your `.csproj`:
```xml
<Target Name="CopyOpenVINOLibraries" AfterTargets="Build">
<Copy SourceFiles="$(NuGetPackageRoot)fluid.openvino.genai\2025.3.0-dev20250801\runtimes\win-x64\native\*.dll"
DestinationFolder="$(OutputPath)"
SkipUnchangedFiles="true" />
</Target>
```

### Issue 3: Platform Mismatch

**Symptoms:**
- `BadImageFormatException` errors
- "Wrong format" or architecture mismatch errors

**Solutions:**

1. **Ensure x64 Platform**
Your project must target x64:
```xml
<PropertyGroup>
<PlatformTarget>x64</PlatformTarget>
<Platforms>x64</Platforms>
</PropertyGroup>
```

2. **Verify Runtime Identifier**
For self-contained deployments:
```xml
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<!-- or -->
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
```

### Issue 4: Linux-Specific Issues

**Symptoms:**
- Libraries found but fail to load on Linux
- Missing dependency errors

**Solutions:**

1. **Set LD_LIBRARY_PATH**
```bash
export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH
dotnet run
```

2. **Check Dependencies**
```bash
ldd libopenvino_genai_c.so
```

3. **Install System Dependencies**
```bash
# Ubuntu/Debian
sudo apt-get install libtbb2

# RHEL/CentOS
sudo yum install tbb
```

## Validation Script

Create a simple test project to validate the package:

```csharp
using System;
using System.IO;
using Fluid.OpenVINO.GenAI;

class Program
{
static void Main()
{
Console.WriteLine("Testing Fluid.OpenVINO.GenAI...");

// Test managed assembly
var config = GenerationConfig.Default;
Console.WriteLine($"✓ GenerationConfig created: MaxTokens={config.MaxTokens}");

// Check native libraries
var dlls = new[] { "openvino_genai_c.dll", "openvino_c.dll" };
foreach (var dll in dlls)
{
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, dll);
Console.WriteLine($"{dll}: {(File.Exists(path) ? "✓" : "✗")}");
}
}
}
```

## Package Contents Verification

To verify what's included in the NuGet package:

```powershell
# Extract and inspect package
Copy-Item "package.nupkg" -Destination "package.zip"
Expand-Archive -Path "package.zip" -DestinationPath "package_contents"
Get-ChildItem -Path "package_contents" -Recurse
```

## Build Output

When everything is working correctly, you should see:
- No warnings during build
- Native libraries copied to output directory
- Message: "OpenVINO GenAI: Copied native libraries from ... to ..."

## Getting Help

If issues persist:
1. Check the [GitHub Issues](https://github.com/FluidInference/OpenVINO.GenAI.NET/issues)
2. Enable MSBuild diagnostic logging: `dotnet build -v diag > build.log`
3. Report issues with:
- .NET version (`dotnet --version`)
- Operating system and architecture
- Package version
- Build log excerpt

## Environment Variables

- `OPENVINO_RUNTIME_PATH`: Override automatic library discovery
- `CI`: Set to `true` to suppress warnings in CI/CD environments
- `SuppressOpenVINOWarnings`: Set to `true` to disable all warnings
14 changes: 9 additions & 5 deletions src/OpenVINO.NET.GenAI/Fluid.OpenVINO.GenAI.targets
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<Project>

<PropertyGroup>
<!-- Get the solution directory by going up from this file's directory -->
<SolutionDir>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)../..'))</SolutionDir>

<!-- First check if OPENVINO_RUNTIME_PATH environment variable is set -->
<OpenVINOGenAIRuntimePath Condition="'$(OpenVINOGenAIRuntimePath)' == '' AND '$(OPENVINO_RUNTIME_PATH)' != ''">$(OPENVINO_RUNTIME_PATH)</OpenVINOGenAIRuntimePath>

<!-- Try multiple potential runtime paths to handle different project structures -->
<!-- For NuGet package installations: look for libraries in the package's runtimes folder -->
<!-- When installed via NuGet, this targets file is in packages/Fluid.OpenVINO.GenAI/build/ -->
<!-- The native libraries are in packages/Fluid.OpenVINO.GenAI/runtimes/[rid]/native/ -->
<OpenVINOGenAIRuntimePath Condition="'$(OpenVINOGenAIRuntimePath)' == '' AND $([MSBuild]::IsOSPlatform('Windows')) AND Exists('$(MSBuildThisFileDirectory)..\runtimes\win-x64\native')">$(MSBuildThisFileDirectory)..\runtimes\win-x64\native</OpenVINOGenAIRuntimePath>
<OpenVINOGenAIRuntimePath Condition="'$(OpenVINOGenAIRuntimePath)' == '' AND $([MSBuild]::IsOSPlatform('Linux')) AND Exists('$(MSBuildThisFileDirectory)../runtimes/linux-x64/native')">$(MSBuildThisFileDirectory)../runtimes/linux-x64/native</OpenVINOGenAIRuntimePath>

<!-- For local development: look in the solution's build directory -->
<SolutionDir>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)../..'))</SolutionDir>
<OpenVINOGenAIRuntimePath Condition="'$(OpenVINOGenAIRuntimePath)' == '' AND $([MSBuild]::IsOSPlatform('Windows')) AND Exists('$(SolutionDir)\build\native\runtimes\win-x64\native')">$(SolutionDir)\build\native\runtimes\win-x64\native</OpenVINOGenAIRuntimePath>
<OpenVINOGenAIRuntimePath Condition="'$(OpenVINOGenAIRuntimePath)' == '' AND $([MSBuild]::IsOSPlatform('Windows')) AND Exists('$(MSBuildThisFileDirectory)..\..\build\native\runtimes\win-x64\native')">$(MSBuildThisFileDirectory)..\..\build\native\runtimes\win-x64\native</OpenVINOGenAIRuntimePath>

Expand Down Expand Up @@ -61,7 +65,7 @@
Condition="'$(OPENVINO_RUNTIME_PATH)' != ''" />

<!-- Provide helpful error message with setup instructions -->
<Warning Text="OpenVINO GenAI: Native libraries not found. Please follow setup instructions:&#xA;1. Download OpenVINO GenAI runtime from https://storage.openvinotoolkit.org/repositories/openvino_genai/packages/&#xA;2. Extract to $(SolutionDir)/build/native/runtimes/[win-x64|linux-x64]/native/&#xA;3. Or set OPENVINO_RUNTIME_PATH environment variable to the runtime directory"
<Warning Text="OpenVINO GenAI: Native libraries not found at $(OpenVINOGenAIRuntimePath). Troubleshooting:&#xA;1. If using NuGet package: Ensure package restored correctly and check $(MSBuildThisFileDirectory)..\runtimes\[win-x64|linux-x64]\native\&#xA;2. For local development: Download OpenVINO GenAI runtime from https://storage.openvinotoolkit.org/repositories/openvino_genai/packages/&#xA; Extract to $(SolutionDir)/build/native/runtimes/[win-x64|linux-x64]/native/&#xA;3. For custom installations: Set OPENVINO_RUNTIME_PATH environment variable to your runtime directory"
Condition="'@(OpenVINOGenAINativeLibraries)' == '' AND '$(SuppressOpenVINOWarnings)' != 'true'" />
</Target>

Expand Down
35 changes: 27 additions & 8 deletions src/OpenVINO.NET.GenAI/OpenVINO.NET.GenAI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<!-- Multi-target .NET 6.0 (LTS), .NET 7.0, and .NET 8.0 (LTS) -->
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -15,28 +16,42 @@
<RepositoryUrl>https://github.com/FluidInference/OpenVINO.GenAI.NET</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>openvino;ai;inference;llm;genai;machine-learning;deep-learning;neural-networks;text-generation</PackageTags>
<PackageTags>openvino;ai;inference;llm;genai;machine-learning;deep-learning;neural-networks;text-generation;whisper;speech-to-text</PackageTags>
<AssemblyVersion>2025.3.0.0</AssemblyVersion>
<FileVersion>2025.3.0.0</FileVersion>
<Version>2025.3.0.0-dev20250801</Version>
<Version>2025.3.0.1</Version>
<Platforms>x64</Platforms>
<PlatformTarget>x64</PlatformTarget>
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
<PackageReleaseNotes>
Fluid.OpenVINO.GenAI 2025.3.0.0-dev20250801
Fluid.OpenVINO.GenAI 2025.3.0.1

Community-maintained C# wrapper for OpenVINO GenAI.

IMPORTANT FIX:
- Fixed NuGet package native library bundling and MSBuild targets
- Native libraries now properly deploy on both Windows and Linux
- Added multi-targeting for .NET 6.0, 7.0, and 8.0

Requirements:
- .NET 8.0 or later
- .NET 6.0, 7.0, or 8.0
- Windows x64 or Linux x64
- OpenVINO GenAI 2025.3.0.0.dev20250801 runtime
- OpenVINO GenAI 2025.3.0.0.dev20250801 runtime (included)

Features:
- Async/await and IAsyncEnumerable streaming
- LLM Pipeline with streaming support (IAsyncEnumerable)
- Whisper Pipeline for speech-to-text
- Fluent configuration API
- Automatic native library management
- Automatic native library management via MSBuild targets
- SafeHandle resource management

Changes in 2025.3.0.1:
- Fixed MSBuild targets to correctly resolve native libraries from NuGet package
- Added support for .NET 6.0 and 7.0 (previously only .NET 8.0)
- Improved error messages for missing native libraries
- Added comprehensive troubleshooting documentation
- All 27 OpenVINO native libraries now properly included for Windows
- Linux native libraries included for Ubuntu 24.04
</PackageReleaseNotes>
</PropertyGroup>

Expand All @@ -60,8 +75,10 @@
<Content Include="..\..\build\native\runtimes\win-x64\native\*.dll">
<PackagePath>runtimes\win-x64\native\%(Filename)%(Extension)</PackagePath>
<Pack>true</Pack>
<PackageCopyToOutput>false</PackageCopyToOutput>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Link>runtimes\win-x64\native\%(Filename)%(Extension)</Link>
<Visible>false</Visible>
</Content>
</ItemGroup>

Expand All @@ -70,8 +87,10 @@
<Content Include="..\..\build\native\runtimes\linux-x64\native\*.so*">
<PackagePath>runtimes/linux-x64/native/%(Filename)%(Extension)</PackagePath>
<Pack>true</Pack>
<PackageCopyToOutput>false</PackageCopyToOutput>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Link>runtimes/linux-x64/native/%(Filename)%(Extension)</Link>
<Visible>false</Visible>
</Content>
</ItemGroup>

Expand Down
Loading
Loading