Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Tensorflow-GPU on WSL2

Has anyone successfully installed Tensorflow-GPU on WSL2 with NVIDIA GPUs? I have Ubuntu 18.04 on WSL2, but am struggling to get NVIDIA drivers installed. Any help would be appreciated as I'm lost.

like image 842
A. Hendry Avatar asked Sep 01 '20 00:09

A. Hendry


1 Answers

So I have just got this running.

The steps you need to follow are here. To summarise them:

  1. sign up for windows insider program and get the development builds of windows so that you have the latest version
  2. Install wsl 2
  3. Install Ubuntu from the windows store
  4. Install the wsl 2 cuda driver on windows
  5. Install cuda toolkit
  6. Install cudnn (you can download the linux version from windows and then copy the file to linux)
  7. If you are getting memory errors like 'cannot allocate memory' then you might need to increase the amount of memory wsl can get
  8. Then install tensorflow-gpu
  9. pray it works

bugs I hit along the way:

  • If when you open ubuntu for the first time you get an error you need to enable virutalisation in the bios
  • If you cannot run the ./Blackscholes example in the installation instructions you might not have the right build of windows! You must have the right version
  • if you are getting 'cannot allocate memory' errors when running tf you need to give wsl more ram. It only access half your ram by default
    1. create a .wslconfig file under your user directory in windows with the amount of memory you want. Mine looks like:
[wsl2]
memory=16GB 

Edit after running some code

This is much slower then when I was running on windows directly. I went from 1 minute per epoch to 5 minutes. I'm just going to dualboot.

like image 72
Ben Avatar answered Oct 07 '22 08:10

Ben