forked from dotnet/machinelearning
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modified the project to support running of TensorFlow on GPU on Windo…
…ws. (dotnet#4270) * Modified the project to support running of TensorFlow on GPU on Windows. Removed all dependencies of TensorFlow redist from the source projects, and instead added the dependency to the Sample project. Created separate sample project for GPU examples since gpu tensorflow requires cuda, which may not be available on all machines, so it needs to be a separate project. Added documentation for setup as there is now some requirements. * Added NuGet dependency to the test packages which need TensorFlow. * Changed to use the Dependency variable for the TF version. * removed erronious newlines.
- Loading branch information
Showing
9 changed files
with
148 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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,36 @@ | ||
## Using TensorFlow based APIs | ||
In order to run any TensorFlow based ML.Net APIs you must first add a NuGet dependency | ||
on the TensorFlow redist library. There are currently two versions you can use. One which is | ||
compiled for GPU support, and one which has CPU support only. | ||
|
||
### CPU only | ||
CPU based TensorFlow is currently supported on: | ||
* Linux | ||
* MacOS | ||
* Windows | ||
|
||
To get TensorFlow working on the CPU only all that is to take a NuGet dependency on | ||
SciSharp.TensorFlow.Redist v1.14.0 | ||
|
||
### GPU support | ||
GPU based TensorFlow is currently supported on: | ||
* Windows | ||
|
||
#### Prerequisites | ||
You must have at least one CUDA compatible GPU, for a list of compatible GPUs see | ||
[Nvidia's Guide](https://developer.nvidia.com/cuda-gpus). | ||
|
||
Install [CUDA v10.0](https://developer.nvidia.com/cuda-10.0-download-archive) and [CUDNN v7.6.4](https://developer.nvidia.com/rdp/cudnn-download) | ||
following [Nvidia's Install guide](https://docs.nvidia.com/cuda/cuda-quick-start-guide/index.html). | ||
|
||
#### Usage | ||
To use TensorFlow with GPU support take a NuGet dependency on the following package depending on your OS: | ||
|
||
Windows -> SciSharp.TensorFlow.Redist-Windows-GPU | ||
|
||
No code modification should be necessary to leverage the GPU for TensorFlow operations. | ||
|
||
#### Troubleshooting | ||
If you are not able to use your GPU after adding the GPU based TensorFlow NuGet, | ||
make sure that there is only a dependency on the GPU based version. If you have | ||
a dependency on both NuGets, the CPU based TensorFlow will run instead. |
63 changes: 63 additions & 0 deletions
63
docs/samples/Microsoft.ML.Samples.GPU/Microsoft.ML.Samples.GPU.csproj
This file contains 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,63 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
<OutputType>Exe</OutputType> | ||
<SignAssembly>false</SignAssembly> | ||
<!--This ensures that we can never make the mistake of adding this as a friend assembly. Please don't remove.--> | ||
<PublicSign>false</PublicSign> | ||
<RootNamespace>Samples</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\Microsoft.ML.Samples\Program.cs" Link="Program.cs" /> | ||
<Compile Include="..\Microsoft.ML.Samples\Dynamic\ImageClassification\*.cs"> | ||
<Link>Dynamic\ImageClassification\%(FileName)</Link> | ||
</Compile> | ||
<Compile Include="..\Microsoft.ML.Samples\Dynamic\TensorFlow\*.cs"> | ||
<Link>Dynamic\TensorFlow\%(FileName)</Link> | ||
</Compile> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\src\Microsoft.ML.Dnn\Microsoft.ML.Dnn.csproj" /> | ||
<ProjectReference Include="..\..\..\src\Microsoft.ML.TensorFlow\Microsoft.ML.TensorFlow.csproj" /> | ||
<ProjectReference Include="..\..\..\src\Microsoft.ML.SamplesUtils\Microsoft.ML.SamplesUtils.csproj" /> | ||
|
||
<NativeAssemblyReference Include="CpuMathNative" /> | ||
<NativeAssemblyReference Include="FastTreeNative" /> | ||
<NativeAssemblyReference Include="MatrixFactorizationNative" /> | ||
<NativeAssemblyReference Include="LdaNative" /> | ||
<NativeAssemblyReference Include="SymSgdNative" /> | ||
<NativeAssemblyReference Include="MklProxyNative" /> | ||
|
||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.ML.Onnx.TestModels" Version="$(MicrosoftMLOnnxTestModelsVersion)" /> | ||
<PackageReference Include="SciSharp.TensorFlow.Redist-Windows-GPU" Version="$(TensorFlowVersion)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="$(ObjDir)DnnImageModels\ResNet18Onnx\ResNet18.onnx"> | ||
<Link>DnnImageModels\ResNet18Onnx\ResNet18.onnx</Link> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="$(ObjDir)DnnImageModels\ResNetPrepOnnx\ResNetPreprocess.onnx"> | ||
<Link>DnnImageModels\ResNetPrepOnnx\ResNetPreprocess.onnx</Link> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Dynamic\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains 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 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 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 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 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 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