Unverified 提交 035ac82e authored 作者: NanoCode012's avatar NanoCode012 提交者: GitHub

Fix torch multi-GPU --device error (#1701)

* Fix torch GPU error * Update torch_utils.py single-line device = Co-authored-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com>
上级 69ea70cd
......@@ -75,13 +75,14 @@ def time_synchronized():
return time.time()
def profile(x, ops, n=100, device=torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')):
def profile(x, ops, n=100, device=None):
# profile a pytorch module or list of modules. Example usage:
# x = torch.randn(16, 3, 640, 640) # input
# m1 = lambda x: x * torch.sigmoid(x)
# m2 = nn.SiLU()
# profile(x, [m1, m2], n=100) # profile speed over 100 iterations
device = device or torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
x = x.to(device)
x.requires_grad = True
print(torch.__version__, device.type, torch.cuda.get_device_properties(0) if device.type == 'cuda' else '')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论