You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tools.py里
我用cpu进行训练,n_gpu=‘’,
def prepare_device(use_gpu):
"""
setup GPU device if available, move model into configured device
# 如果n_gpu_use为数字,则使用range生成list
# 如果输入的是一个list,则默认使用list[0]作为controller
Example:
use_gpu = '' : cpu
use_gpu = '0': cuda:0
use_gpu = '0,1' : cuda:0 and cuda:1
"""
# use_gpu = ''
n_gpu_use = [int(x) for x in use_gpu.split(",")]
if not use_gpu:
device_type = 'cpu'
else:
device_type = f"cuda:{n_gpu_use[0]}"
n_gpu = torch.cuda.device_count()
if len(n_gpu_use) > 0 and n_gpu == 0:
logger.warning("Warning: There's no GPU available on this machine, training will be performed on CPU.")
device_type = 'cpu'
if len(n_gpu_use) > n_gpu:
msg = f"Warning: The number of GPU's configured to use is {n_gpu}, but only {n_gpu} are available on this machine."
logger.warning(msg)
n_gpu_use = range(n_gpu)
device = torch.device(device_type)
list_ids = n_gpu_use
return device, list_ids
这里n_gpu_use = [int(x) for x in use_gpu.split(",")]会报错,原因是use_gpu是空的字符串,不能int.
The text was updated successfully, but these errors were encountered:
tools.py里
我用cpu进行训练,n_gpu=‘’,
def prepare_device(use_gpu):
"""
setup GPU device if available, move model into configured device
# 如果n_gpu_use为数字,则使用range生成list
# 如果输入的是一个list,则默认使用list[0]作为controller
Example:
use_gpu = '' : cpu
use_gpu = '0': cuda:0
use_gpu = '0,1' : cuda:0 and cuda:1
"""
# use_gpu = ''
n_gpu_use = [int(x) for x in use_gpu.split(",")]
if not use_gpu:
device_type = 'cpu'
else:
device_type = f"cuda:{n_gpu_use[0]}"
n_gpu = torch.cuda.device_count()
if len(n_gpu_use) > 0 and n_gpu == 0:
logger.warning("Warning: There's no GPU available on this machine, training will be performed on CPU.")
device_type = 'cpu'
if len(n_gpu_use) > n_gpu:
msg = f"Warning: The number of GPU's configured to use is {n_gpu}, but only {n_gpu} are available on this machine."
logger.warning(msg)
n_gpu_use = range(n_gpu)
device = torch.device(device_type)
list_ids = n_gpu_use
return device, list_ids
这里n_gpu_use = [int(x) for x in use_gpu.split(",")]会报错,原因是use_gpu是空的字符串,不能int.
The text was updated successfully, but these errors were encountered: