How to use the lightwood.config.config.CONFIG.USE_DEVICE function in lightwood

To help you get started, we’ve selected a few lightwood examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mindsdb / lightwood / lightwood / helpers / device.py View on Github external
def get_devices():
    device_str = "cuda" if CONFIG.USE_CUDA else "cpu"
    if CONFIG.USE_DEVICE is not None:
        device_str = CONFIG.USE_DEVICE
    device = torch.device(device_str)

    available_devices = 1
    if device_str == 'cuda':
        available_devices = torch.cuda.device_count()

    return device, available_devices
github mindsdb / lightwood / lightwood / mixers / helpers / default_net.py View on Github external
def __init__(self, ds, dynamic_parameters, shape=None, selfaware=False, size_parameters={}, pretrained_net=None):
        self.input_size = None
        self.output_size = None
        self.selfaware = selfaware
        # How many devices we can train this network on
        self.available_devices = 1
        self.max_variance = None
        if ds is not None:
            self.out_indexes = ds.out_indexes

        device_str = "cuda" if CONFIG.USE_CUDA else "cpu"
        if CONFIG.USE_DEVICE is not None:
            device_str = CONFIG.USE_DEVICE
        self.device = torch.device(device_str)

        if CONFIG.DETERMINISTIC:
            '''
                Seed that always has the same value on the same dataset plus setting the bellow CUDA options
                In order to make sure pytorch randomly generate number will be the same every time
                when training on the same dataset
            '''
            if ds is not None:
                torch.manual_seed(len(ds))
            else:
                torch.manual_seed(2)

            if device_str == 'cuda':
                torch.backends.cudnn.deterministic = True
github mindsdb / lightwood / lightwood / mixers / helpers / default_net.py View on Github external
def __init__(self, ds, dynamic_parameters, shape=None, selfaware=False, size_parameters={}, pretrained_net=None):
        self.input_size = None
        self.output_size = None
        self.selfaware = selfaware
        # How many devices we can train this network on
        self.available_devices = 1
        self.max_variance = None
        if ds is not None:
            self.out_indexes = ds.out_indexes

        device_str = "cuda" if CONFIG.USE_CUDA else "cpu"
        if CONFIG.USE_DEVICE is not None:
            device_str = CONFIG.USE_DEVICE
        self.device = torch.device(device_str)

        if CONFIG.DETERMINISTIC:
            '''
                Seed that always has the same value on the same dataset plus setting the bellow CUDA options
                In order to make sure pytorch randomly generate number will be the same every time
                when training on the same dataset
            '''
            if ds is not None:
                torch.manual_seed(len(ds))
            else:
                torch.manual_seed(2)

            if device_str == 'cuda':
                torch.backends.cudnn.deterministic = True
                torch.backends.cudnn.benchmark = False
github mindsdb / lightwood / lightwood / helpers / device.py View on Github external
def get_devices():
    device_str = "cuda" if CONFIG.USE_CUDA else "cpu"
    if CONFIG.USE_DEVICE is not None:
        device_str = CONFIG.USE_DEVICE
    device = torch.device(device_str)

    available_devices = 1
    if device_str == 'cuda':
        available_devices = torch.cuda.device_count()

    return device, available_devices