PaddlePaddle / PaddlePaddle/Paddle

[DeviceId] GetCurrentDeviceId 和 _global_expected_place_ 是否完全无关?

Open
#41,865 3 comments 0 reactions 1 assignee View on GitHub

@zhangting2020 is already working on this.

Since Apr 15, 2022.

status/following-up type/question
Dominant language
C++
Stars
24.1k
Forks
6k
Avg merge
4d 17h
Merged PRs (30d)
60

Description

请提出你的问题 Please ask your question

paddle 目前的 place 是一个 python 端全局的对象。
https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/framework.py#L517-L520

def _set_expected_place(place):
    global _global_expected_place_
    _global_expected_place_ = place
    _set_dygraph_tracer_expected_place(place)

请问跟 https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/phi/backends/gpu/cuda/cuda_info.cc#L170-L174

int GetCurrentDeviceId() {
  int device_id;
  PADDLE_ENFORCE_GPU_SUCCESS(cudaGetDevice(&device_id));
  return device_id;
}

中的 GetCurrentDeviceId 是不是完全没有关联。

C++中如何获取当前place的 device id.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.