Skip to content

[WIP] LibTorch upgrade #1486

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

Draft
wants to merge 39 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
a2bdfdb
test initial attempt libtorch upgrade
alinpahontu2912 Jul 7, 2025
2b27ed2
enable testing
alinpahontu2912 Jul 7, 2025
abc1ec6
retrigger
alinpahontu2912 Jul 7, 2025
bef4ed8
run build cuda packages
alinpahontu2912 Jul 8, 2025
38036ff
Merge branch 'main' of https://github.com/alinpahontu2912/TorchSharp
alinpahontu2912 Jul 8, 2025
03705b8
enable all workflows
alinpahontu2912 Jul 8, 2025
27e2da7
retrigger
alinpahontu2912 Jul 8, 2025
c0e8863
retrigger
alinpahontu2912 Jul 8, 2025
2f49628
revert to original azure pipelines
alinpahontu2912 Jul 8, 2025
af70eec
build libtorch cuda workflow test
alinpahontu2912 Jul 8, 2025
d351d20
undo pipelines changes
alinpahontu2912 Jul 8, 2025
dda1f74
disable fork pull request check
alinpahontu2912 Jul 8, 2025
61e98a1
use correct cuda version in azure pipelines
alinpahontu2912 Jul 8, 2025
8c5526c
test conditions
alinpahontu2912 Jul 8, 2025
78216cf
set buildlibtorchpackages to true
alinpahontu2912 Jul 10, 2025
5756844
test build and sign
alinpahontu2912 Jul 10, 2025
31fc2a3
fix conditions
alinpahontu2912 Jul 10, 2025
a857f27
change condition
alinpahontu2912 Jul 10, 2025
b934907
test
alinpahontu2912 Jul 10, 2025
b286d78
undo comment
alinpahontu2912 Jul 10, 2025
3b07255
test
alinpahontu2912 Jul 10, 2025
50f81a6
add debug to pack.proj
alinpahontu2912 Jul 11, 2025
72e656f
extra debugging
alinpahontu2912 Jul 11, 2025
405e479
test
alinpahontu2912 Jul 11, 2025
1ef86ff
update names
alinpahontu2912 Jul 11, 2025
bba4f59
split linux cuda packages
alinpahontu2912 Jul 14, 2025
a1201f8
attempt restitch windows packages
alinpahontu2912 Jul 14, 2025
be72ff5
disable parallel windows cuda and linux cuda jobs
alinpahontu2912 Jul 14, 2025
ca39c83
fix condition
alinpahontu2912 Jul 14, 2025
35b39a0
update packages project files
alinpahontu2912 Jul 14, 2025
b71b98b
minimize jobs
alinpahontu2912 Jul 14, 2025
1fe0996
change jobs dependencies
alinpahontu2912 Jul 14, 2025
def759f
change dependencies
alinpahontu2912 Jul 14, 2025
acdc68c
test new approach
alinpahontu2912 Jul 15, 2025
1b18547
fix yaml styling
alinpahontu2912 Jul 15, 2025
4e064f6
restitch windows cuda packages
alinpahontu2912 Jul 15, 2025
c985303
update cuda nuggets splits
alinpahontu2912 Jul 15, 2025
9f6d291
add missing windows cuda dll
alinpahontu2912 Jul 17, 2025
80449e9
update cuda load dll
alinpahontu2912 Jul 17, 2025
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: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<SourceDir>$(RepoRoot)src/</SourceDir>
<PkgDir>$(RepoRoot)pkg/</PkgDir>

<LibTorchPackageVersion>2.5.1.0</LibTorchPackageVersion>
<LibTorchPackageVersion>2.7.1.0</LibTorchPackageVersion>
<LibTorchPackageVersion Condition="'$(TargetOS)' == 'mac' and '$(TargetArchitecture)' == 'x64'">2.2.2.0</LibTorchPackageVersion>

<!-- when building on local machines the massive downloads get placed up one directory -->
Expand Down Expand Up @@ -86,7 +86,7 @@
<!-- use stable versions for libtorch packages based on LibTorch version number scheme-->
<!-- we manually update these -->
<PropertyGroup Condition="'$(MSBuildProjectName.IndexOf(`libtorch-`))' != '-1'">
<LibTorchPackageVersion>2.5.1.0</LibTorchPackageVersion>
<LibTorchPackageVersion>2.7.1.0</LibTorchPackageVersion>
<LibTorchPackageVersion Condition="'$(TargetOS)' == 'mac' and '$(TargetArchitecture)' == 'x64'">2.2.2.0</LibTorchPackageVersion>
<EnablePackageValidation>false</EnablePackageValidation>
<VersionPrefix>$(LibTorchPackageVersion)</VersionPrefix>
Expand Down
5 changes: 3 additions & 2 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<NativeAssemblyReference Include="cudnn_ops64_9" Variant="cuda\" />
<NativeAssemblyReference Include="cufft64_11" Variant="cuda\" />
<NativeAssemblyReference Include="cufftw64_11" Variant="cuda\" />
<NativeAssemblyReference Include="cupti64_2023.1.1" Variant="cuda\" />
<NativeAssemblyReference Include="cupti64_2025.1.0" Variant="cuda\" />
<NativeAssemblyReference Include="curand64_10" Variant="cuda\" />
<NativeAssemblyReference Include="cusolver64_11" Variant="cuda\" />
<NativeAssemblyReference Include="cusolverMg64_11" Variant="cuda\" />
Expand All @@ -49,8 +49,9 @@
<NativeAssemblyReference Include="libiompstubs5md" Variant="cuda\" />
<NativeAssemblyReference Include="nvJitLink_120_0" Variant="cuda\" />
<NativeAssemblyReference Include="nvToolsExt64_1" Variant="cuda\" />
<NativeAssemblyReference Include="nvrtc-builtins64_121" Variant="cuda\" />
<NativeAssemblyReference Include="nvrtc-builtins64_128" Variant="cuda\" />
<NativeAssemblyReference Include="nvrtc64_120_0" Variant="cuda\" />
<NativeAssemblyReference Include="nvrtc64_120_0.alt" Variant="cuda\" />
<NativeAssemblyReference Include="torch" Variant="cuda\" />
<NativeAssemblyReference Include="torch_cpu" Variant="cuda\" />
<NativeAssemblyReference Include="torch_cuda" Variant="cuda\" />
Expand Down
18 changes: 7 additions & 11 deletions TorchSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TorchSharp", "TorchSharp",
pkg\TorchSharp\TorchSharp.symbols.nupkgproj = pkg\TorchSharp\TorchSharp.symbols.nupkgproj
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibTorchSharp", "bin\obj\x64.Debug\Native\LibTorchSharp\LibTorchSharp.vcxproj", "{CAD9DB7F-3223-3324-884D-FA2381593DA7}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibTorchSharp", "bin\obj\x64.Debug\Native\LibTorchSharp\LibTorchSharp.vcxproj", "{E7467DDF-893C-38A8-8E19-6B4E3FB10F55}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibTorchSharp", "bin\obj\x64.Release\Native\LibTorchSharp\LibTorchSharp.vcxproj", "{BB811429-0DF1-3D22-B664-09C2F5A9E0AB}"
EndProject
Expand All @@ -46,7 +46,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Redist", "Redist", "{D8C60CD8-8429-45F2-A755-47B6CD10FDF8}"
ProjectSection(SolutionItems) = preProject
src\Redist\libtorch-cpu\libtorch-cpu.proj = src\Redist\libtorch-cpu\libtorch-cpu.proj
src\Redist\libtorch-cuda-12.1\libtorch-cuda-12.1.proj = src\Redist\libtorch-cuda-12.1\libtorch-cuda-12.1.proj
src\Redist\libtorch-cuda-12.8\libtorch-cuda-12.8.proj = src\Redist\libtorch-cuda-12.8\libtorch-cuda-12.8.proj
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Native-Release", "Native-Release", "{4DB9E84D-324C-408F-87A6-246E86205540}"
Expand Down Expand Up @@ -107,14 +107,10 @@ Global
{42B45168-476D-4BFA-87B8-81A34E6295CD}.Release|Any CPU.Build.0 = Release|Any CPU
{42B45168-476D-4BFA-87B8-81A34E6295CD}.Release|x64.ActiveCfg = Release|Any CPU
{42B45168-476D-4BFA-87B8-81A34E6295CD}.Release|x64.Build.0 = Release|Any CPU
{CAD9DB7F-3223-3324-884D-FA2381593DA7}.Debug|Any CPU.ActiveCfg = Debug|x64
{CAD9DB7F-3223-3324-884D-FA2381593DA7}.Debug|x64.ActiveCfg = Debug|x64
{CAD9DB7F-3223-3324-884D-FA2381593DA7}.Release|Any CPU.ActiveCfg = Release|x64
{CAD9DB7F-3223-3324-884D-FA2381593DA7}.Release|x64.ActiveCfg = Release|x64
{E4C0DBEE-0815-311B-9065-137BB50BD793}.Debug|Any CPU.ActiveCfg = Debug|x64
{E4C0DBEE-0815-311B-9065-137BB50BD793}.Debug|x64.ActiveCfg = Debug|x64
{E4C0DBEE-0815-311B-9065-137BB50BD793}.Release|Any CPU.ActiveCfg = Release|x64
{E4C0DBEE-0815-311B-9065-137BB50BD793}.Release|x64.ActiveCfg = Release|x64
{E7467DDF-893C-38A8-8E19-6B4E3FB10F55}.Debug|Any CPU.ActiveCfg = Debug|x64
{E7467DDF-893C-38A8-8E19-6B4E3FB10F55}.Debug|x64.ActiveCfg = Debug|x64
{E7467DDF-893C-38A8-8E19-6B4E3FB10F55}.Release|Any CPU.ActiveCfg = Release|x64
{E7467DDF-893C-38A8-8E19-6B4E3FB10F55}.Release|x64.ActiveCfg = Release|x64
{DD652544-711E-4029-83FF-DA4A9600E6E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD652544-711E-4029-83FF-DA4A9600E6E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD652544-711E-4029-83FF-DA4A9600E6E7}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -180,7 +176,7 @@ Global
{6C323B05-9028-4B09-911C-3C03AE058BEE} = {AED9C836-31E3-4F3F-8ABC-929555D3F3C4}
{42B45168-476D-4BFA-87B8-81A34E6295CD} = {09EADF06-BE25-4228-AB53-95AE3E15B530}
{567456AD-B026-4CB6-B98D-4FC930C90223} = {D3D38B03-B557-484D-8348-8BADEE4DF592}
{CAD9DB7F-3223-3324-884D-FA2381593DA7} = {CF2C1A9E-3A8A-4329-8A6E-7880C15AAC3D}
{E7467DDF-893C-38A8-8E19-6B4E3FB10F55} = {CF2C1A9E-3A8A-4329-8A6E-7880C15AAC3D}
{BB811429-0DF1-3D22-B664-09C2F5A9E0AB} = {4DB9E84D-324C-408F-87A6-246E86205540}
{CF2C1A9E-3A8A-4329-8A6E-7880C15AAC3D} = {09EADF06-BE25-4228-AB53-95AE3E15B530}
{D8C60CD8-8429-45F2-A755-47B6CD10FDF8} = {09EADF06-BE25-4228-AB53-95AE3E15B530}
Expand Down
19 changes: 11 additions & 8 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ parameters:
# push them to the artifacts feed of the Azure CI project
- name: BuildLibTorchPackages
type: boolean
default: false
default: true
- name: PushPackagesToFeed
type: boolean
default: false

# Set which source branch to build libtorch-* packages.
# The build-libtorch jobs are only run if the source branch is the same as this value.
# The default is 'main' branch.
Expand Down Expand Up @@ -117,7 +118,7 @@ jobs:
condition: eq('${{ parameters.BuildLibTorchPackages }}', true)
displayName: Download libtorch native binaries

- script: dotnet build -c $(BuildConfig) src/Redist/libtorch-cuda-12.1/libtorch-cuda-12.1.proj /p:UpdateSHA=true /p:SkipTests=true /p:TargetOS=linux /t:Build /p:IncludeLibTorchCudaPackages=true
- script: dotnet build -c $(BuildConfig) src/Redist/libtorch-cuda-12.8/libtorch-cuda-12.8.proj /p:UpdateSHA=true /p:SkipTests=true /p:TargetOS=linux /t:Build /p:IncludeLibTorchCudaPackages=true
condition: eq('${{ parameters.BuildLibTorchPackages }}', true)
displayName: Download libtorch native CUDA binaries

Expand Down Expand Up @@ -157,7 +158,7 @@ jobs:
- script: dotnet build -c $(BuildConfig) src/Redist/libtorch-cpu/libtorch-cpu.proj /p:UpdateSHA=true /p:SkipTests=true /p:TargetOS=windows /t:Build /p:IncludeLibTorchCpuPackages=true
displayName: Download libtorch native binaries

- script: dotnet build -c $(BuildConfig) src/Redist/libtorch-cuda-12.1/libtorch-cuda-12.1.proj /p:UpdateSHA=true /p:SkipTests=true /p:TargetOS=windows /t:Build /p:IncludeLibTorchCudaPackages=true
- script: dotnet build -c $(BuildConfig) src/Redist/libtorch-cuda-12.8/libtorch-cuda-12.8.proj /p:UpdateSHA=true /p:SkipTests=true /p:TargetOS=windows /t:Build /p:IncludeLibTorchCudaPackages=true
condition: eq('${{ parameters.BuildLibTorchPackages }}', true)
displayName: Download libtorch native CUDA binaries

Expand Down Expand Up @@ -348,9 +349,10 @@ jobs:
# Only run if BuildLibTorchPackages is true
- job: Build_libtorch_cuda_win_Packages
################################################################################
condition: and(ne(variables['system.pullrequest.isfork'], true), eq(variables['build.sourcebranchname'], '${{ parameters.SourceBranchName }}'), eq('${{ parameters.BuildLibTorchPackages }}', true))
condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), eq(variables['build.sourcebranchname'], '${{ parameters.SourceBranchName }}'), eq('${{ parameters.BuildLibTorchPackages }}', true))
dependsOn:
- Windows_Native_Build_For_Packages
- Build_TorchSharp_And_libtorch_cpu_Packages
variables:
BuildConfig: Release
OfficialBuildId: $(BUILD.BUILDNUMBER)
Expand Down Expand Up @@ -382,7 +384,7 @@ jobs:
- script: dotnet restore pkg/pack.proj /p:Configuration=Release
displayName: Restore package projects

- script: dotnet pack -c $(BuildConfig) --no-build -v:n /p:SkipNative=true /p:SkipTests=true /p:IncludeTorchSharpPackage=false /p:IncludeLibTorchCpuPackages=false /p:IncludeLibTorchCudaPackages=true pkg/pack.proj
- script: dotnet pack -c $(BuildConfig) --no-build -v:n /p:SkipNative=true /p:SkipTests=true /p:IncludeTorchSharpPackage=false /p:IncludeLibTorchCpuPackages=false /p:IncludeLibTorchCudaPackages=true /p:TargetOS=windows pkg/pack.proj
displayName: Create Packages

# We are 10GB space-constrained on the Azure Pipelines CI system so clean up what we can
Expand All @@ -403,9 +405,10 @@ jobs:
################################################################################
- job: Build_libtorch_cuda_linux_Packages
################################################################################
condition: and(ne(variables['system.pullrequest.isfork'], true), eq(variables['build.sourcebranchname'], '${{ parameters.SourceBranchName }}'), eq('${{ parameters.BuildLibTorchPackages }}', true))
condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), eq(variables['build.sourcebranchname'], '${{ parameters.SourceBranchName }}'), eq('${{ parameters.BuildLibTorchPackages }}', true))
dependsOn:
- Linux_Native_Build_For_Packages
- Build_libtorch_cuda_win_Packages
variables:
BuildConfig: Release
OfficialBuildId: $(BUILD.BUILDNUMBER)
Expand Down Expand Up @@ -448,7 +451,7 @@ jobs:
- script: dotnet restore pkg/pack.proj /p:Configuration=Release
displayName: Restore package projects

- script: dotnet pack -c $(BuildConfig) --no-build -v:n /p:SkipNative=true /p:SkipTests=true /p:ApiCompatGenerateSuppressionFile=true /p:IncludeTorchSharpPackage=false /p:IncludeLibTorchCpuPackages=false /p:IncludeLibTorchCudaPackages=true pkg/pack.proj
- script: dotnet pack -c $(BuildConfig) --no-build -v:n /p:SkipNative=true /p:SkipTests=true /p:ApiCompatGenerateSuppressionFile=true /p:IncludeTorchSharpPackage=false /p:IncludeLibTorchCpuPackages=false /p:IncludeLibTorchCudaPackages=true /p:TargetOS=linux pkg/pack.proj
displayName: Create Packages

# We are 10GB space-constrained on the Azure Pipelines CI system so clean up what we can
Expand Down Expand Up @@ -859,4 +862,4 @@ jobs:
publishVstsFeed: 'TorchSharp/TestPackages'
allowPackageConflicts: true
# often fails - try but ignore the error until we sort it out
continueOnError: true
continueOnError: true
4 changes: 2 additions & 2 deletions build/BranchInfo.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<MajorVersion>0</MajorVersion>
<MinorVersion>105</MinorVersion>
<PatchVersion>1</PatchVersion>
<PreviousPackageVersion>0.105.0</PreviousPackageVersion>
<PatchVersion>2</PatchVersion>
<PreviousPackageVersion>0.105.1</PreviousPackageVersion>
</PropertyGroup>
</Project>
6 changes: 3 additions & 3 deletions build/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

<!-- Other/Non-Core Product Dependencies -->
<PropertyGroup>
<LibTorchVersion>2.5.1</LibTorchVersion>
<LibTorchVersion>2.7.1</LibTorchVersion>
<LibTorchVersion Condition="'$(TargetArchitecture)' == 'x64' and '$(TargetOS)' == 'mac'">2.2.2</LibTorchVersion>
<CudaVersionDot>12.1</CudaVersionDot>
<CudaVersionNoDot>121</CudaVersionNoDot>
<CudaVersionDot>12.8</CudaVersionDot>
<CudaVersionNoDot>128</CudaVersionNoDot>
<MklDnnVersion>2019.0.5.20190502</MklDnnVersion>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion pkg/TorchSharp-cuda-linux/TorchSharp-cuda-linux.nupkgproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<ItemGroup>
<ProjectReference Include="..\TorchSharp\TorchSharp.nupkgproj" />
<ProjectReference Include="..\libtorch-cuda-12.1-linux-x64\libtorch-cuda-12.1-linux-x64.nupkgproj" />
<ProjectReference Include="..\libtorch-cuda-12.8-linux-x64\libtorch-cuda-12.8-linux-x64.nupkgproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<ItemGroup>
<ProjectReference Include="..\TorchSharp\TorchSharp.nupkgproj" />
<ProjectReference Include="..\libtorch-cuda-12.1-win-x64\libtorch-cuda-12.1-win-x64.nupkgproj" />
<ProjectReference Include="..\libtorch-cuda-12.8-win-x64\libtorch-cuda-12.8-win-x64.nupkgproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Pack">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
</ItemGroup>

<ItemGroup>
<Content Include="..\common\NormalPackage.props" Pack="true" PackagePath="buildTransitive\netstandard2.0\$(MSBuildProjectName).props" />
<Content Include="..\common\NormalPackage.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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Pack">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
</ItemGroup>

<ItemGroup>
<Content Include="..\common\NormalPackage.props" Pack="true" PackagePath="buildTransitive\netstandard2.0\$(MSBuildProjectName).props" />
<Content Include="..\common\NormalPackage.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>
Loading