Post image unsplash-logo Pierre Bamin

The first part of this guide was a short overview on TensorFlow and machine learning with Rust in general. In this part we will install the TensorFlow libraries and set up the dependencies needed to run TensorFlow from Rust with GPU support.

In order to run a Rust program with TensorFlow GPU support we need the following:

  • Rust
  • TensorFlow language bindings for C
  • Latest GPU drivers
  • CUDA® Toolkit
  • cuDNN SDK

I will assume you have Rust installed, if not follow the official instructions for installing.

TensorFlow language bindings for C

Visit TensorFlow’s download page for the C bindings and download the Windows version with GPU support. Extract the files to any location suitable for libraries, for this guide I’m going to use:

%USERPROFILE%\lib

Inside the newly extracted TensorFlow folder we find another lib folder. This should be added to the Windows Path variable. You can modify the PATH variable through Windows Control Panel -> Edit the system environment variables.

So in my case I got version 1.14.0 of the language bindings, so the following path is appended to the existing PATH environment variable:

%USERPROFILE%\lib\libtensorflow-gpu-windows-x86_64-1.14.0\lib

Latest GPU drivers

Make sure you have a CUDA® enabled GPU and visit the download page for NVIDIA® drivers and download and install the latest available drivers for your GPU.

CUDA® Toolkit

Visit the CUDA® Toolkit download page and download a version of your choice. For this guide we will use CUDA® 10.0.

After installing we need to add the bin folder of the toolkit to the windows Path variable, just like we did for the TensorFlow library above.

In my case, the following path is appended to the PATH variable:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin

cuDNN SDK

In order to download cuDNN SDK, you need to be registered in the NVIDIA® Developer Program. Visit the cuDNN site, follow the download links for cuDNN to get to the registration process. Once registered and logged in, you get access to download cuDNN SDK. Make sure to download a version matching the CUDA® Toolkit version you installed above. Extract the files to a suitable location, again we’re going to use %USERPROFILE%\lib.

The bin folder of the extraced cuDNN files should be added to Windows PATH variable as well. The folder to add in our case would be:

%USERPROFILE%\lib\cuda\bin

And we are done setting up TensorFlow C bindings and dependencies! In the next and final part of the series we will configure and run a sample Rust program that builds and trains a small Neural Network.

Tags: