How to set specific gpu in tensorflow?

There are 3 ways to achieve this: Using CUDA_VISIBLE_DEVICES environment variable. by setting environment variable CUDA_VISIBLE_DEVICES=”1″ makes only device 1 visible and by setting CUDA_VISIBLE_DEVICES=”0,1″ makes devices 0 and 1 visible. You can do this in python by having a line os.environ[“CUDA_VISIBLE_DEVICES”]=”0,1″ after importing os package. Using with tf.device(‘/gpu:2’) and creating the graph. Then it … Read more