未验证 提交 ea72e31f 编写于 作者: W wopeizl 提交者: GitHub

fix issue on windows (#2848)

* fix gpu detection issue on windows
1. use the fluid.core.get_cuda_device_count() to decide the GPU number
2. ignore the path missing issue
上级 173d5e65
......@@ -207,16 +207,14 @@ def process_image(sample,
return (img, )
def image_mapper(**kwargs):
""" image_mapper """
return functools.partial(process_image, **kwargs)
def process_batch_data(input_data, settings, mode, color_jitter, rotate):
batch_data = []
for sample in input_data:
batch_data.append(
process_image(sample, settings, mode, color_jitter, rotate))
if os.path.isfile(sample[0]):
batch_data.append(
process_image(sample, settings, mode, color_jitter, rotate))
else:
print("File not exist : %s" % sample[0])
return batch_data
......
......@@ -338,13 +338,9 @@ def build_program(is_train, main_prog, startup_prog, args):
def get_device_num():
# NOTE(zcd): for multi-processe training, each process use one GPU card.
if num_trainers > 1 : return 1
visible_device = os.environ.get('CUDA_VISIBLE_DEVICES', None)
if visible_device:
device_num = len(visible_device.split(','))
else:
device_num = subprocess.check_output(['nvidia-smi','-L']).decode().count('\n')
return device_num
if num_trainers > 1:
return 1
return fluid.core.get_cuda_device_count()
def train(args):
# parameters from arguments
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册