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

Support inference for GCU #14142

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

EnflameGCU
Copy link

@EnflameGCU EnflameGCU commented Nov 1, 2024

配置GCU设备的推理流程

@GreatV GreatV requested a review from jzhang533 November 1, 2024 10:31
tools/infer/utility.py Outdated Show resolved Hide resolved
@@ -41,6 +41,7 @@ def init_args():
parser.add_argument("--use_xpu", type=str2bool, default=False)
parser.add_argument("--use_npu", type=str2bool, default=False)
parser.add_argument("--use_mlu", type=str2bool, default=False)
parser.add_argument("--use_gcu", type=str2bool, default=False)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please include a short message to help user understand its purpose.
To me, at the first glance, I am guessing gcu stands for GraphCore Unit, realized it's Enflame's device after searching.

Other arguments(i.e.: uie_xpu, use_npu, use_mlu) also need help message to clarify the respective devices, but could be addressed in separate PRs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks for pointing that out. I'll add comments to GCU first.

I am afraid that our description of other arguments may not be accurate, and they may need to be described by the developers of the corresponding hardware manufacturers.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid that our description of other arguments may not be accurate, and they may need to be described by the developers of the corresponding hardware manufacturers.

agree

Comment on lines 44 to 46
parser.add_argument(
"--use_gcu", type=str2bool, default=False
) # Use Enflame GCU(General Compute Unit)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
parser.add_argument(
"--use_gcu", type=str2bool, default=False
) # Use Enflame GCU(General Compute Unit)
parser.add_argument(
"--use_gcu", type=str2bool, default=False,
help="Use Enflame GCU(General Compute Unit)",
)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your suggestion.

@@ -41,6 +41,7 @@ def init_args():
parser.add_argument("--use_xpu", type=str2bool, default=False)
parser.add_argument("--use_npu", type=str2bool, default=False)
parser.add_argument("--use_mlu", type=str2bool, default=False)
parser.add_argument("--use_gcu", type=str2bool, default=False)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid that our description of other arguments may not be accurate, and they may need to be described by the developers of the corresponding hardware manufacturers.

agree

@@ -293,6 +299,28 @@ def create_predictor(args, mode, logger):
config.enable_custom_device("mlu")
elif args.use_xpu:
config.enable_xpu(10 * 1024 * 1024)
elif args.use_gcu: # for Enflame GCU(General Compute Unit)
import paddle_custom_device.gcu.passes as gcu_passes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we first check whether the paddle_custom_device package is present? If it’s not, remind the user to install it first?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your suggestion.

if paddle.framework.use_pir_api():
config.enable_new_ir(True)
config.enable_new_executor(True)
kPirGcuPasses = gcu_passes.inference_passes(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to build passes based on "PaddleOCR" or "PaddleXXX"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to optimize performance based on hardware features and even network structure, and the processing here is to increase this flexibility.

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

Successfully merging this pull request may close these issues.

5 participants