Module: Candle::DeviceUtils

Defined in:
lib/candle/device_utils.rb

Class Method Summary collapse

Class Method Details

.best_deviceObject

Get the best available device (Metal > CUDA > CPU)



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/candle/device_utils.rb', line 4

def self.best_device
  # Try devices in order of preference
  begin
    # Try Metal first (for Mac users)
    Device.metal
  rescue
    # :nocov:
    begin
      # Try CUDA next (for NVIDIA GPU users)
      Device.cuda
    rescue
      # Fall back to CPU
      Device.cpu
    end
    # :nocov:
  end
end