Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

tensorflow configure multiple gpu

import tensorflow as tf

c = []
for i, d in enumerate(['/gpu:0', '/gpu:1', '/gpu:2']):
    with tf.device(d):
        a = tf.get_variable(f"a_{i}", [2, 3], initializer=tf.random_uniform_initializer(-1, 1))
        b = tf.get_variable(f"b_{i}", [3, 2], initializer=tf.random_uniform_initializer(-1, 1))
        c.append(tf.matmul(a, b))

with tf.device('/cpu:0'):
    sum = tf.add_n(c)

sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

init = tf.global_variables_initializer()
sess.run(init)

print(sess.run(sum))
# [[-0.36499196 -0.07454088]
# [-0.33966339  0.30250686]]
Comment

PREVIOUS NEXT
Code Example
Python :: watchlist flask app 
Python :: configure socketio static file python specific content type 
Python :: Python NumPy repeat Function Example Working with 1D array 
Python :: Python NumPy hsplit Function 
Python :: how to add to an exsiting value of an index in a list 
Python :: Stacked or grouped bar char python 
Python :: python __div__ 
Python :: Python __ge__ magic method 
Python :: sorting a specific row python 
Python :: p0, percent, aug (inhabitants coming or leaving each year), p (population to surpass) 
Python :: godot knockback 
Python :: NumPy invert Code When the input is a number 
Python :: django admin auto update date field 
Python :: qt list widget let editable 
Python :: Python matplotlib multiple bars 
Python :: config.ini list not string 
Python :: bouton 
Python :: cv2 recize 
Python :: Data Extraction in Python 
Python :: pixel accuracy image segmentation python 
Python :: empty list 
Python :: first duplicate 
Python :: singke line expresions python 
Python :: EDA dataframe get missing and zero values 
Python :: install pythong to custom location 
Python :: qtextedit insert unicode 
Python :: get length of list python 
Python :: open file find and replace commas python 
Python :: python launch ipython from script 
Python :: placeholder in model form 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =