Skip to content

Add Gaudi support to yolov3 #2618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions torchbenchmark/models/yolov3/yolo_utils/torch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,27 @@ def init_seeds(seed=0):


def select_device(device="", apex=False, batch_size=None):
# device = 'cpu', 'xpu' or '0' or '0,1,2,3'
# device = 'cpu', 'xpu', 'hpu' or '0' or '0,1,2,3'
cpu_request = device.lower() == "cpu"
xpu_request = device.lower() == "xpu"
hpu_request = device.lower() == "hpu"
if (
device and not cpu_request and not xpu_request
): # if device requested other than 'cpu'and 'xpu'
device and not cpu_request and not xpu_request and not hpu_request
): # if device requested other than 'cpu', 'xpu' and 'hpu
os.environ["CUDA_VISIBLE_DEVICES"] = device # set environment variable
assert torch.cuda.is_available(), (
"CUDA unavailable, invalid device %s requested" % device
) # check availablity

cuda = False if cpu_request or xpu_request else torch.cuda.is_available()
cuda = False if cpu_request or xpu_request or hpu_request else torch.cuda.is_available()
if cuda:
return torch.device(f"cuda:{torch.cuda.current_device()}")

if xpu_request:
elif xpu_request:
print("Using XPU")
return torch.device(f"xpu:{torch.xpu.current_device()}")

elif hpu_request:
print("Using HPU")
return torch.device(f"hpu:{torch.hpu.current_device()}")
print("Using CPU")
return torch.device("cpu")

Expand Down