class Chainer::GpuDevice

Attributes

id[R]

Public Class Methods

new(id = nil) click to toggle source

@param [Integer] id GPU Device ID. If not given, CUDA current device id is used.

# File lib/chainer/device.rb, line 65
def initialize(id = nil)
  Chainer::CUDA.check_available
  id ||= Cumo::CUDA::Runtime.cudaGetDevice
  if id < 0
    raise 'GPU Device ID must not be negative'
  end
  @id = id
end

Public Instance Methods

==(other) click to toggle source
# File lib/chainer/device.rb, line 78
def ==(other)
  return false unless other.is_a?(GpuDevice)
  id == other.id
end
use() click to toggle source

Sets CUDA current device with owned GPU Device ID

# File lib/chainer/device.rb, line 84
def use
  Cumo::CUDA::Runtime.cudaSetDevice(@id)
end
xm() click to toggle source
# File lib/chainer/device.rb, line 74
def xm
  Cumo
end