Skip to content
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

有bug #72

Open
ZouRuia opened this issue Feb 7, 2022 · 0 comments
Open

有bug #72

ZouRuia opened this issue Feb 7, 2022 · 0 comments

Comments

@ZouRuia
Copy link

ZouRuia commented Feb 7, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant