Skip to content

Using GPU with Tensorflow.NET

Eli Belash edited this page Dec 17, 2019 · 9 revisions

Installing Tensorflow.NET-GPU on Windows

This article will explains in steps how to install Tensorflow-GPU to work with Tensorflow.NET in a C# project.

  1. Make sure your projects are targeting x64 as tensorflow does not support x32 architecture.

  2. Uninstall any existing tensorflow redist packages and install one of the following:

    PM> Install-Package SciSharp.TensorFlow.Redist-Windows-GPU

    Rebuild your project, ensure that tensorflow.dll is copied to your output folder (e.g. bin/debug/tensorflow.dll) and check its size, it should be above 300MB.

  3. You need to meet tensorflow-gpu's requirements.

  • Check if your GPU card has with CUDA® Compute Capability 3.5 or higher. See the list of CUDA-enabled GPU cards.
  • CUDA 10.0 (exactly version 10.0) installed and have the following environment variables set (the directory may vary, verify it exists)
    ::Set new environment variables:
    CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0
    CUDA_PATH_V10_0=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0
    ::Append To PATH:
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\extras\CUPTI\libx64
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\include
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin
  • cuDNN SDK installed. Extract the zip to C:\cudann and set up the environment variable in PATH:
    ::Append to PATH:
    C:\cudann
    C:\cudann\bin
  • Make sure your NVIDIA GPU driver version is >=410.x (after you've installed CUDA 10.0 as it might reinstall your current drivers).

If you've done all the above correctly, the library should automatically switch to GPU and console should print a line similar to this:
tensorflow/core/common_runtime/gpu/gpu_device.cc:1326] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 2114 MB memory) -> 
physical GPU (device: 0, name: GeForce GTX 1060 3GB, pci bus id: 0000:04:00.0, compute capability: 6.1)
Clone this wiki locally