Having issue with adding visible gpu devices: 0

Viewed 1360

I m using my gpu for computation on my laptop where I have seen that gpu 0 is for my integrated graphic card and 1 is my nvidia 1050 external graphic card . (from the task manager) i just want to make sure during the compilation my pycharm compiler uses gpu 1 but I am unable to do so.

Here is the log details....

2020-05-06 21:00:06.478540: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2020-05-06 21:00:20.723309: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1096] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-05-06 21:00:20.724072: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102]      0 
2020-05-06 21:00:20.724203: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] 0:   N 
2020-05-06 21:00:20.787933: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1241] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 2997 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1050, pci bus id: 0000:01:00.0, compute capability: 6.1)
WARNING:tensorflow:Large dropout rate: 0.7 (>0.5). In TensorFlow 2.x, dropout() uses dropout rate instead of keep_prob. Please ensure that this is intended.
2020-05-06 21:00:38.294984: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-05-06 21:00:45.280700: W tensorflow/stream_executor/gpu/redzone_allocator.cc:312] Internal: Invoking GPU asm compilation is supported on Cuda non-Windows platforms only
Relying on driver to perform ptx compilation. This message will be only logged once.
2020-05-06 21:00:45.449255: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2020-05-06 21:01:05.026230: W tensorflow/core/common_runtime/bfc_allocator.cc:243] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.15GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.

Process finished with exit code 0
2 Answers

Your integrated graphics card won't be used for computation.
TensorFlow officially supports NVIDIA gpus.
See hardware requirements.

This is why you see only gpu 0 as available device.
2020-05-06 21:00:06.478540: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0

If having multiple devices: Try Manual device placement

tf.debugging.set_log_device_placement(True)

# Place tensors on the GPU 1
with tf.device('/GPU:1'): # assuming your config recognizes GPU 1
  a = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
  b = tf.constant([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])

c = tf.matmul(a, b)
print(c)

Not sure why, but adding these 2 lines of code before importing tensorflow fixed the issue

import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'

(Ref here)

Related