-
Notifications
You must be signed in to change notification settings - Fork 724
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
映射文档 No.120 #5966
Conversation
感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-5966.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html |
paddle.CUDAPlace(id) | ||
``` | ||
|
||
其中 Pytorch 与 Paddle 的参数类型不一致,具体如下: |
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.
参数支持类型不一致
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.
已修改
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ------------------------------------------------------- | | ||
| device | id | GPU 的设备 ID, PyTorch 比 Paddle 多 torch.device 类型。 | |
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.
Pytorch支持torch.device和int,而Paddle仅支持int。需要进行转写。
然后下面针对 torch输入torch.device时的情况,写一下 转写示例
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.
已修改
|
||
# 增加 index | ||
# Pytorch 写法 | ||
torch.cuda.device(torch.device('cuda', index=1)) |
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.
这个转写方式是:获取device参数,对其取device.index值
改成那种吧
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.
已修改
|
||
```python | ||
# Pytorch 写法 | ||
torch.cuda.device(torch.device('cuda').index) |
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.
这样吧
torch.cuda.device(torch.device('cuda'))
paddle.CUDAPlace(0)
torch.cuda.device(torch.device('cuda', index=index))
paddle.CUDAPlace(index)
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.
已修改
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.
LGTM
PaddlePaddle/PaConvert#112
api是 torch.cuda.device