Class: Chainer::GpuDevice
- Inherits:
-
AbstractDevice
- Object
- AbstractDevice
- Chainer::GpuDevice
- Defined in:
- lib/chainer/device.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(id = nil) ⇒ GpuDevice
constructor
A new instance of GpuDevice.
-
#use ⇒ Object
Sets CUDA current device with owned GPU Device ID.
- #xm ⇒ Object
Constructor Details
#initialize(id = nil) ⇒ GpuDevice
Returns a new instance of GpuDevice.
65 66 67 68 69 70 71 72 |
# 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 |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
62 63 64 |
# File 'lib/chainer/device.rb', line 62 def id @id end |
Instance Method Details
#==(other) ⇒ Object
78 79 80 81 |
# File 'lib/chainer/device.rb', line 78 def ==(other) return false unless other.is_a?(GpuDevice) id == other.id end |
#use ⇒ Object
Sets CUDA current device with owned GPU Device ID
84 85 86 |
# File 'lib/chainer/device.rb', line 84 def use Cumo::CUDA::Runtime.cudaSetDevice(@id) end |
#xm ⇒ Object
74 75 76 |
# File 'lib/chainer/device.rb', line 74 def xm Cumo end |