Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there R command(s) making Keras Tensorflow-GPU to run on CPU?

I'm running Keras in R and using Tensorflow-GPU backend. Is it possible to force Keras to run on CPU without re-installing the backend?

like image 738
Dmitri Vasserman Avatar asked Jul 01 '18 23:07

Dmitri Vasserman


People also ask

Can TensorFlow GPU run on CPU?

TensorFlow supports running computations on a variety of types of devices, including CPU and GPU.

Does keras use GPU automatically?

If your system has an NVIDIA® GPU and you have the GPU version of TensorFlow installed then your Keras code will automatically run on the GPU.


1 Answers

Let me give you 2 answers.

Answer #1 (normal answer)

No, unfortunately not. For keras CPU and GPU are 2 different versions, from which you select at install time.

It seems you remember that you selected GPU at install time. I guess you're hoping that you were only setting a minor option, not selecting a version of the program. Unfortunately, you were selecting the version of keras to install.

Answer #2 (ok, maybe you can "trick" keras)

It seems you can use environment variable values to trick keras into thinking that your CPU is your GPU.

This seems like it may have unexpected results, but it seemed to work for these Python users.

I wouldn't worry about the fact that they are using Python. They are just using their language to set environment variables. So you can do the same in R or directly within your OS.

like image 67
Hack-R Avatar answered Sep 22 '22 05:09

Hack-R