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

映射文档 No.120 #5966

Merged
merged 2 commits into from
Jul 5, 2023
Merged

映射文档 No.120 #5966

merged 2 commits into from
Jul 5, 2023

Conversation

co63oc
Copy link
Contributor

@co63oc co63oc commented Jun 25, 2023

PaddlePaddle/PaConvert#112

api是 torch.cuda.device

@paddle-bot
Copy link

paddle-bot bot commented Jun 25, 2023

感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-5966.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html
预览工具的更多说明,请参考:飞桨文档预览工具

paddle.CUDAPlace(id)
```

其中 Pytorch 与 Paddle 的参数类型不一致,具体如下:
Copy link
Collaborator

Choose a reason for hiding this comment

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

参数支持类型不一致

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改


| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | ------------------------------------------------------- |
| device | id | GPU 的设备 ID, PyTorch 比 Paddle 多 torch.device 类型。 |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pytorch支持torch.device和int,而Paddle仅支持int。需要进行转写。

然后下面针对 torch输入torch.device时的情况,写一下 转写示例

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改


# 增加 index
# Pytorch 写法
torch.cuda.device(torch.device('cuda', index=1))
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个转写方式是:获取device参数,对其取device.index值
改成那种吧

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改


```python
# Pytorch 写法
torch.cuda.device(torch.device('cuda').index)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这样吧

torch.cuda.device(torch.device('cuda'))

paddle.CUDAPlace(0)

torch.cuda.device(torch.device('cuda', index=index))

paddle.CUDAPlace(index)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

Copy link
Collaborator

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

LGTM

@zhwesky2010 zhwesky2010 merged commit 1314f82 into PaddlePaddle:develop Jul 5, 2023
3 checks passed
@co63oc co63oc deleted the api120 branch July 25, 2023 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants