0

These are the activated devices that I have:

[name: "/device:CPU:0" device_type: "CPU" memory_limit: 268435456 locality { } incarnation: 5415837867258701517 , name: "/device:GPU:0" device_type: "GPU" memory_limit: 3198956339 locality { bus_id: 1 links { } } incarnation: 12462133041849407996 physical_device_desc: "device: 0, name: GeForce GTX 960M, pci bus id: 0000:01:00.0, compute capability: 5.0" ] 

What I want to do is to configure my program to use GeForce GTX 960M and also make this configuration permanent for all my previous/future programs if is it possible?

8
  • By default, TensorFlow will try to run things on the GPU if possible (if there is a GPU available and operations can be run in it). You can use tf.device to that a section of the code must be run on the GPU or fail otherwise (unless you use allow_soft_placement, see Using GPUs). With multiple GPUs, you can select which ones CUDA use with CUDA_VISIBLE_DEVICES, but I don't think that's your problem. Commented Aug 2, 2019 at 12:01
  • @jdehesa: Thank you! But do you know how can I switch between using GPU or CPU? I want to make sure which of those I am using know and compare using them. Commented Aug 2, 2019 at 12:44
  • As I said, with tf.device you can choose what device you want to use (GPU or CPU), and with CUDA_VISIBLE_DEVICES you can disable the GPU completely (setting it to -1). You can also disable the GPU per-session, see How to run Tensorflow on CPU. Commented Aug 2, 2019 at 12:50
  • @jdehesa: I put os.environ['CUDA_VISIBLE_DEVICES'] = '1' in the begining of my program but no difference happend! Commented Aug 2, 2019 at 12:59
  • To disable the GPU, you would need to put os.environ['CUDA_VISIBLE_DEVICES'] = '-1' at the beginning before importing TensorFlow for the first time. Commented Aug 2, 2019 at 13:05

1 Answer 1

1

try with the function: set_visible_devices

physical_devices = tf.config.list_physical_devices('GPU') tf.config.set_visible_devices(physical_devices[1:],'GPU') 

Where you can specify which GPUs you would like to use

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.