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

TPU available: true when there are no TPUs #3104

Closed
dalmia opened this issue Aug 22, 2020 · 6 comments · Fixed by #3274
Closed

TPU available: true when there are no TPUs #3104

dalmia opened this issue Aug 22, 2020 · 6 comments · Fixed by #3274
Labels
accelerator: tpu Tensor Processing Unit bug Something isn't working
Milestone

Comments

@dalmia
Copy link

dalmia commented Aug 22, 2020

🐛 Bug

I am using a DGX machine (and so, no TPUs), but on initiating Trainer, it logs TPU available: True. This ends up returning Missing XLA configuration when I run my script.

To Reproduce

Code sample

Simply running the following lines on my machine:

>> trainer = pl.Trainer(gpus=[0])                                                                                                                 
GPU available: True, used: True
TPU available: True, using: 0 TPU cores

Expected behavior

>> trainer = pl.Trainer(gpus=[0])                                                                                                                 
GPU available: True, used: True
TPU available: False, using: 0 TPU cores

Environment

* CUDA:
        - GPU:
                - Tesla V100-SXM2-32GB
        - available:         True
        - version:           10.2
* Packages:
        - numpy:             1.18.2
        - pyTorch_debug:     False
        - pyTorch_version:   1.6.0
        - pytorch-lightning: 0.9.0
        - tensorboard:       2.2.0
        - tqdm:              4.45.0
* System:
        - OS:                Linux
        - architecture:
                - 64bit
                - 
        - processor:         x86_64
        - python:            3.6.9
        - version:           #168-Ubuntu SMP Wed Jan 16 21:00:45 UTC 2019
@dalmia dalmia added bug Something isn't working help wanted Open to be worked on labels Aug 22, 2020
@Borda
Copy link
Member

Borda commented Aug 24, 2020

sounds like some misconfiguration issue, are interested in sending a PR? 🐰

@Borda Borda added the accelerator: tpu Tensor Processing Unit label Aug 24, 2020
@dalmia
Copy link
Author

dalmia commented Aug 28, 2020

Sure. I realized that the bug is in this script.

Specifically:

try:
    import torch_xla.core.xla_model as xm
except ImportError:
    XLA_AVAILABLE = False
else:
    XLA_AVAILABLE = True

So, if the environment has torch_xla installed but no TPU, then this error is thrown. If I use an environment without torch_xla, it works fine. So, is this something that should be fixed in the codebase or something that the user should take care of? @Borda

@Borda
Copy link
Member

Borda commented Aug 28, 2020

yes, we had the XLA detection as a temporal solution as we did not expect someone would install XLA without having TPU...
so, pls send a PR, I think that we have this patter in several files...

@edenlightning edenlightning added this to the 0.9.x milestone Sep 1, 2020
@stale
Copy link

stale bot commented Oct 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the won't fix This will not be worked on label Oct 1, 2020
@rohitgr7 rohitgr7 removed the won't fix This will not be worked on label Oct 1, 2020
@edenlightning edenlightning modified the milestones: 0.9.x, 1.0 Oct 4, 2020
@edenlightning edenlightning removed the help wanted Open to be worked on label Oct 5, 2020
@alimoezzi
Copy link

I faced this issue on gcloud vm with gpu but not tpu.

Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/site-packages/pytorch_lightning/utilities/xla_device.py", line 32, in inner_f
    queue.put(func(*args, **kwargs))
  File "/opt/conda/lib/python3.7/site-packages/pytorch_lightning/utilities/xla_device.py", line 73, in _is_device_tpu
    return (xm.xrt_world_size() > 1) or bool(xm.get_xla_supported_devices("TPU"))
  File "/opt/conda/lib/python3.7/site-packages/torch_xla/core/xla_model.py", line 137, in get_xla_supported_devices
    xla_devices = _DEVICES.value
  File "/opt/conda/lib/python3.7/site-packages/torch_xla/utils/utils.py", line 32, in value
    self._value = self._gen_fn()
  File "/opt/conda/lib/python3.7/site-packages/torch_xla/core/xla_model.py", line 19, in <lambda>
    _DEVICES = xu.LazyProperty(lambda: torch_xla._XLAC._xla_get_devices())
RuntimeError: tensorflow/compiler/xla/xla_client/computation_client.cc:273 : Missing XLA configuration

The torch_xla was installed by default in the Deep learning image and the only solution was to manually uninstall torch_xla
I used PL latest version 1.6.4

@apezzi
Copy link

apezzi commented Sep 20, 2022

@realsarm this worked for me, on gcloud with one gpu but not tpu.
On the shell launched pip uninstall torch_xla.

Thanks a lot :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accelerator: tpu Tensor Processing Unit bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants