-
Notifications
You must be signed in to change notification settings - Fork 213
Windows Arm Support #1493
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
Open
cm4ker
wants to merge
3
commits into
dotnet:main
Choose a base branch
from
cm4ker:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Windows Arm Support #1493
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
pkg/libtorch-cpu-win-arm64/libtorch-cpu-win-arm64.nupkgproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Pack"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="..\common\CpuHeadPackage.props" Pack="true" PackagePath="buildTransitive\netstandard2.0\$(MSBuildProjectName).props" /> | ||
<Content Include="..\common\CpuHeadPackage.targets" Pack="true" PackagePath="buildTransitive\netstandard2.0\$(MSBuildProjectName).targets" /> | ||
<Content Include="..\empty.txt" Pack="true" PackagePath="lib\netstandard2.0\_._" /> | ||
<Content Include="$(RepoRoot)\THIRD-PARTY-NOTICES.txt" Pack="true" PackagePath="LICENSE-LIBTORCH.txt" /> | ||
</ItemGroup> | ||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/Redist/libtorch-cpu/libtorch-win-arm64-shared-with-deps-2.7.1%2Bcpu.zip.sha
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
F9DD47C792C900601F08265DDC0186036E01503ADA7895F0C7C90F8AF64FBC4B |
1 change: 1 addition & 0 deletions
1
src/Redist/libtorch-cpu/libtorch-win-arm64-shared-with-deps-debug-2.7.1%2Bcpu.zip.sha
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DFDD2BECA32B1B3D4894EFA801DC60570849F0ED47A318734BA798A5C4D6513B |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,13 +36,13 @@ public static partial class torch | |
RuntimeInformation.OSArchitecture == Architecture.Arm64; | ||
|
||
static string nativeRid => | ||
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? $"win-x64" : | ||
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ($"win-{(RuntimeInformation.OSArchitecture == Architecture.Arm64 ? "arm64" : "x64")}") : | ||
RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? $"linux-x64" : | ||
isAppleSilicon ? "osx-arm64" : | ||
"any"; | ||
|
||
static string nativeGlob => | ||
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @".*\.dll" : | ||
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @".*\.dll$" : | ||
RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? @".*\.dylib\.*" : | ||
// must match | ||
// lib.so | ||
|
@@ -127,7 +127,8 @@ private static void LoadNativeBackend(bool useCudaBackend, out StringBuilder? tr | |
|
||
if (useCudaBackend) { | ||
var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); | ||
if (isWindows) { | ||
// CUDA is not supported on Windows ARM64. Only attempt to load CUDA components on Windows x64. | ||
if (isWindows && RuntimeInformation.OSArchitecture == Architecture.X64) { | ||
trace.AppendLine($" Try loading Windows cuda native components"); | ||
// Preloading these DLLs on windows seems to iron out problems where one native DLL | ||
// requests a load of another through dynamic linking techniques. | ||
|
@@ -151,9 +152,49 @@ private static void LoadNativeBackend(bool useCudaBackend, out StringBuilder? tr | |
|
||
ok = TryLoadNativeLibraryByName("torch_cuda", typeof(torch).Assembly, trace); | ||
ok = TryLoadNativeLibraryByName("LibTorchSharp", typeof(torch).Assembly, trace); | ||
|
||
// On Windows, also attempt direct absolute-path loads from the assembly directory | ||
if (!ok && isWindows) { | ||
var asmDir = Path.GetDirectoryName(typeof(torch).Assembly.Location)!; | ||
var torchCudaPath = Path.Combine(asmDir, "torch_cuda.dll"); | ||
var libTorchSharpPath = Path.Combine(asmDir, "LibTorchSharp.dll"); | ||
trace.AppendLine($" Attempting absolute-path load of native components from {asmDir}..."); | ||
ok = TryLoadNativeLibraryFromFile(torchCudaPath, trace); | ||
if (ok) ok = TryLoadNativeLibraryFromFile(libTorchSharpPath, trace); | ||
} | ||
} else { | ||
ok = TryLoadNativeLibraryByName("torch_cpu", typeof(torch).Assembly, trace); | ||
ok = TryLoadNativeLibraryByName("LibTorchSharp", typeof(torch).Assembly, trace); | ||
var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
if (isWindows) { | ||
// Preload dependency chain explicitly on Windows: torch_global_deps -> c10 -> uv -> torch -> torch_cpu -> LibTorchSharp | ||
trace.AppendLine($" Try loading Windows CPU native dependency chain: torch_global_deps -> c10 -> uv -> torch -> torch_cpu -> LibTorchSharp"); | ||
ok = TryLoadNativeLibraryByName("torch_global_deps", typeof(torch).Assembly, trace); | ||
if (ok) ok = TryLoadNativeLibraryByName("c10", typeof(torch).Assembly, trace); | ||
if (ok) ok = TryLoadNativeLibraryByName("uv", typeof(torch).Assembly, trace); | ||
if (ok) ok = TryLoadNativeLibraryByName("torch", typeof(torch).Assembly, trace); | ||
if (ok) ok = TryLoadNativeLibraryByName("torch_cpu", typeof(torch).Assembly, trace); | ||
if (ok) ok = TryLoadNativeLibraryByName("LibTorchSharp", typeof(torch).Assembly, trace); | ||
} else { | ||
ok = TryLoadNativeLibraryByName("torch_cpu", typeof(torch).Assembly, trace); | ||
if (ok) ok = TryLoadNativeLibraryByName("LibTorchSharp", typeof(torch).Assembly, trace); | ||
} | ||
|
||
// On Windows, also attempt direct absolute-path loads from the assembly directory | ||
if (!ok && isWindows) { | ||
var asmDir = Path.GetDirectoryName(typeof(torch).Assembly.Location)!; | ||
var torchGlobalDepsPath = Path.Combine(asmDir, "torch_global_deps.dll"); | ||
var c10Path = Path.Combine(asmDir, "c10.dll"); | ||
var uvPath = Path.Combine(asmDir, "uv.dll"); | ||
var torchPath = Path.Combine(asmDir, "torch.dll"); | ||
var torchCpuPath = Path.Combine(asmDir, "torch_cpu.dll"); | ||
var libTorchSharpPath = Path.Combine(asmDir, "LibTorchSharp.dll"); | ||
trace.AppendLine($" Attempting absolute-path load of native components from {asmDir}..."); | ||
ok = TryLoadNativeLibraryFromFile(torchGlobalDepsPath, trace); | ||
if (ok) ok = TryLoadNativeLibraryFromFile(c10Path, trace); | ||
if (ok) ok = TryLoadNativeLibraryFromFile(uvPath, trace); | ||
if (ok) ok = TryLoadNativeLibraryFromFile(torchPath, trace); | ||
if (ok) ok = TryLoadNativeLibraryFromFile(torchCpuPath, trace); | ||
if (ok) ok = TryLoadNativeLibraryFromFile(libTorchSharpPath, trace); | ||
} | ||
} | ||
|
||
trace.AppendLine($" Result from regular native load of LibTorchSharp is {ok}"); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This package version update appears unrelated to Windows ARM64 support. Consider separating dependency updates into a separate commit to maintain focused changes.
Copilot uses AI. Check for mistakes.