somaticio / tensorflow.rb

tensorflow for ruby
BSD 3-Clause "New" or "Revised" License
827 stars 66 forks source link

Add #device to place ops on specific named devices #67

Open chrhansen opened 8 years ago

chrhansen commented 8 years ago

Used in "Basic Usage" here: https://www.tensorflow.org/versions/r0.10/get_started/basic_usage.html e.g.:

with tf.device('/gpu:2'):
  tf.constant([1.0, 2.0, 3.0], shape=[3], name='a')

Could be something like (using default-graph if not explicitly specified) this in Ruby:

Tensorflow.device('/gpu:2') do
  graph.constant([1.0, 2.0, 3.0], shape: [3], name : 'a')
end

Python API: https://www.tensorflow.org/versions/r0.10/how_tos/using_gpu/index.html#supported-devices