1

I am running a rather memory-intense (estimated to be around 6GB) GAN model with tf.keras which my GPU doesn't seem to be able to handle (predicting fails, reports only nans). Is there a way to support my 4GB GPU memory with system memory? Or a way to share the computational effort between GPU and CPU?

My specs:

  • OS: Windows 10 64
  • GPU: Geforce GTX 960 (4GB)
  • CPU: Intel Xeon-E3 1231 v3 (4 cores)
  • Python GUI: Spyder 5
  • Python: 3.8.5 / 3.8.10 in a conda environment with only the tensorflow and chess module installed
  • Tensorflow: 2.5
  • CUDA: 11.2.2
  • cudnn: 8.1.1

For more information see my very detailed version of this question I asked a couple of days ago (no responses, hence this one): TF model doesn't predict anymore after switching to GPU

BLEB
  • 53
  • 6

1 Answers1

1

Solution:

In tensor flow to train a model with a gpu is the same with any operating system when using python keras.When you train the model you wrap your training function in a with statement specifying the gpu number as a argument for the tf.device method

Here is a template of the code:

import tensorflow as tf

with tf.device('/device:GPU:<The gpu number>'):
    history = model.fit(<your traning info>)

Otherwise if you lack the resources such as RAM CPU GPU then try to use google colab a free environment to program tensor flow with access to many GPUS's CPU's and RAM for free

TERMINATOR
  • 1,180
  • 1
  • 11
  • 24
  • Thanks for the input, TERMINATOR. Since I didn't have any issues activating my GPU, I'm glad you added the reference to Google Colab. That indeed might be the way forward for me. – BLEB Jun 07 '21 at 12:21
  • Can I please ask for a link to the papper you read on his for personal use – TERMINATOR Jun 07 '21 at 14:16
  • I am using code that's originally from the pix2pix project (see https://github.com/phillipi/pix2pix). Victor S has made this model usable in a chess environment here: https://towardsdatascience.com/magnusgan-using-gans-to-play-like-chess-masters-9dded439bc56?gi=f00faa8a2105 – BLEB Jun 07 '21 at 15:01
  • I found something you might be interested in here https://towardsdatascience.com/facemask-detection-using-tensorflow-and-opencv-824b69cad837 – TERMINATOR Jun 07 '21 at 15:05