PR #13106: Fix a bug in AsyncAllocator memory pools access setting.
PR #13106: Fix a bug in AsyncAllocator memory pools access setting.

Imported from GitHub PR https://github.com/openxla/xla/pull/13106

The original code uses the wrong parameter `i` for `cuDeviceCanAccessPeer()`, which can cause undefined behavior when `(*all_ids_)[i] != platform_device_id`, for example, virtual devices are used. Should use `(*all_ids_)[i].value()` to represent the previous pool id.

Also, add a judgment to skip the pool initialization process if it's already initialized previously. This can happen in some cases, such as when multiple virtual devices are created from one physical GPU, the virtual devices will actually share the same CUDA memory pool.

Same PR from TensorFlow repo: https://github.com/tensorflow/tensorflow/pull/67373.
Copybara import of the project:

--
c70708185d10508fe03d4ee760f8640908dcf7f0 by Robin Zhang <robinz@nvidia.com>:

memory pools access initialization

Merging this change closes #13106

FUTURE_COPYBARA_INTEGRATE_REVIEW=https://github.com/openxla/xla/pull/13106 from buptzyb:asyncpool c70708185d10508fe03d4ee760f8640908dcf7f0
