10BC0 Update torch utils to handle passing in a device · Issue #82 · cblearn/cblearn · GitHub
[go: up one dir, main page]

Skip to content

Update torch utils to handle passing in a device #82

@nkondapa

Description

@nkondapa

torch_device() in _torch_utils.py returns None if the device is not set to auto

should add an else statement to the function

Original:

def torch_device(device: str) -> str:
    import torch

    if device == "auto":
        if torch.cuda.is_available():
            return "cuda"
        else:
            return "cpu"

Improved:

def torch_device(device: str) -> str:
    import torch

    if device == "auto":
        if torch.cuda.is_available():
            return "cuda"
        else:
            return "cpu"
    else:
        return device

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0