Skip to content

[DLPACK] Setting device_id in FromDLPACK #68549

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

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

HydrogenSulfate
Copy link
Contributor

@HydrogenSulfate HydrogenSulfate commented Oct 1, 2024

PR Category

Operator Mechanism

PR Types

Bug fixes

Description

Pcard-75624

Issued in NVIDIA/warp#318 (comment), device_id should be set in TensorFromDLPack when in GPU env.
cc @shi-eric

before:

import paddle

x_gpu2 = paddle.randn([2, 2]).to(device='gpu:2')

t_gpu2 = paddle.utils.dlpack.to_dlpack(x_gpu2)

x_gpu2_ref = paddle.utils.dlpack.from_dlpack(t_gpu2)

print(x_gpu2.place, x_gpu2_ref.place)
Place(gpu:2) Place(gpu:0) # device_id of x_gpu2_ref.place is not not set correctly

after fixing:

import paddle

x_gpu2 = paddle.randn([2, 2]).to(device='gpu:2')

t_gpu2 = paddle.utils.dlpack.to_dlpack(x_gpu2)

x_gpu2_ref = paddle.utils.dlpack.from_dlpack(t_gpu2)

print(x_gpu2.place, x_gpu2_ref.place)
Place(gpu:2) Place(gpu:2) # x_gpu2_ref.place is same as x_gpu2

Copy link

paddle-bot bot commented Oct 1, 2024

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

@SigureMo SigureMo merged commit 554f472 into PaddlePaddle:develop Oct 1, 2024
27 checks passed
@HydrogenSulfate HydrogenSulfate deleted the develop1 branch October 2, 2024 12:27
@HydrogenSulfate HydrogenSulfate linked an issue Oct 20, 2024 that may be closed by this pull request
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

Successfully merging this pull request may close these issues.

关于from_dlpack
2 participants