-
Notifications
You must be signed in to change notification settings - Fork 80
[API Compatibility] Add some CUDA device management APIs to NONEED_CONVERT #719
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
Conversation
Thanks for your contribution! |
atol=0.0, | ||
): | ||
assert pytorch_result == int(paddle_result.replace("gpu:", "")) | ||
assert pytorch_result == paddle_result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种也可以直接用APIBase,无需再重写了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的
""" | ||
import torch | ||
torch.cuda.set_device(0) | ||
torch.cuda.set_device("cuda:0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
目前不支持直接set一个int吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
支持的,但是目前有个情况是,写0会有如下报错,改成cuda:0不会报错,本地测试0和cuda:0均可以通过,我继续定位问题
device = 0
2025-09-26 11:59:15
2025-09-26 11:59:15 def set_device(device: DeviceLike) -> None:
2025-09-26 11:59:15 if isinstance(device, int):
2025-09-26 11:59:15 # Convert int device index to string format (e.g., 0 -> 'gpu:0')
2025-09-26 11:59:15 device_place = framework.current_expected_place()
2025-09-26 11:59:15 if isinstance(device_place, core.CUDAPlace):
2025-09-26 11:59:15 device_str = f'gpu:{device}'
2025-09-26 11:59:15 elif isinstance(device_place, core.CustomPlace):
2025-09-26 11:59:15 device_str = f'{device_place.get_device_type()}:{device}'
2025-09-26 11:59:15 elif isinstance(device_place, core.XPUPlace):
2025-09-26 11:59:15 device_str = f'xpu:{device}'
2025-09-26 11:59:15 else:
2025-09-26 11:59:15 > raise ValueError(
2025-09-26 11:59:15 "Paddle-CPU is not supported. Please use PaddlePaddle with CUDA, XPU or Custom Device"
2025-09-26 11:59:15 E ValueError: Paddle-CPU is not supported. Please use PaddlePaddle with CUDA, XPU or Custom Device
上面问题,下个PR修改吧 |
好的 |
PR Docs
向NO_NEED_CONVERT添加一些CUDA 设备管理类API
PR APIs
docs仓库pr:PaddlePaddle/docs#7470