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

[Enhancement] Add xpu option, *test=kunlun #1815

Merged
merged 1 commit into from
Mar 2, 2022
Merged
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
15 changes: 13 additions & 2 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ def parse_args():
help='The option of train profiler. If profiler_options is not None, the train ' \
'profiler is enabled. Refer to the paddleseg/utils/train_profiler.py for details.'
)
parser.add_argument(
'--device',
dest='device',
help='Device place to be set, which can be GPU, XPU, CPU',
default='gpu',
type=str)

return parser.parse_args()

Expand All @@ -137,8 +143,13 @@ def main(args):
['-' * 48])
logger.info(info)

place = 'gpu' if env_info['Paddle compiled with cuda'] and env_info[
'GPUs used'] else 'cpu'
if args.device == 'gpu' and env_info[
'Paddle compiled with cuda'] and env_info['GPUs used']:
place = 'gpu'
elif args.device == 'xpu' and paddle.is_compiled_with_xpu():
place = 'xpu'
else:
place = 'cpu'

paddle.set_device(place)
if not args.cfg:
Expand Down