Xla: Can't import torch_xla in colab

Created on 24 Jun 2020  ยท  11Comments  ยท  Source: pytorch/xla

โ“ Questions and Help

VERSION = "1.5" #@param ["1.5" , "20200325", "nightly"]
!curl https://raw.githubusercontent.com/pytorch/xla/master/contrib/scripts/env-setup.py -o pytorch-xla-env-setup.py
!python pytorch-xla-env-setup.py --version $VERSION

import torch_xla
import torch_xla.core.xla_model as xm
device = xm.xla_device()
print(device)

However the colab cant import torch_xla and return this error

ImportError Traceback (most recent call last)
in ()
----> 1 import torch_xla
2 import torch_xla.core.xla_model as xm
3 device = xm.xla_device()
4 print(device)

/usr/local/lib/python3.6/dist-packages/torch_xla/__init__.py in ()
39 import torch
40 from .version import __version__
---> 41 import _XLAC
42
43 _XLAC._initialize_aten_bindings()

ImportError: /usr/local/lib/python3.6/dist-packages/_XLAC.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN2at6native6einsumENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3c108ArrayRefINS_6TensorEEE

stale

All 11 comments

Must be some local issue, as it works for me.
Did you try nightly or some other version?

This error happens when there is a mismatch between torch and torch_xla. Are you reinstalling torch again after this script runs?

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.

I had this error too. I think this happens because after you install it, it doesn't go straight into the notebook environment. I fixed it by restarting the runtime and not running the install again.

I have the same issue , same error while import torch_xla.

Similar error here
undefined symbol: _ZN2at19slow_conv_dilated3dERKNS_6TensorES2_N3c108ArrayRefIlEES2_S5_S5_S5_

@harsh244, looks like you had a version mismatch where torch==1.7.0 but torch_xla==1.6. We've just updated our colab notebooks: https://github.com/pytorch/xla/pull/2596 can you try again installing torch_xla==1.7 like we updated on those notebooks?

@harsh244, looks like you had a version mismatch where torch==1.7.0 but torch_xla==1.6. We've just updated our colab notebooks: #2596 can you try again installing torch_xla==1.7 like we updated on those notebooks?

@jysohn23 Another error popped up after running the new updated notebook

WARNING:root:TPU has started up successfully with version pytorch-1.6
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-14-ebe519c076f6> in <module>()
      3 
      4 # imports the torch_xla package
----> 5 import torch_xla
      6 import torch_xla.core.xla_model as xm

2 frames
/usr/local/lib/python3.6/dist-packages/torch_xla/_patched_functions.py in _patch(fn, newfn)
     11   xfingerprint = inspect.signature(fn)
     12   fingerprint = inspect.signature(newfn)
---> 13   if xfingerprint != fingerprint:
     14     raise RuntimeError(
     15         'Unable to patch {}, signature mismatch: {} vs {}'.format(

RuntimeError: Unable to patch <function clip_grad_norm_ at 0x7f88ba201f28>, signature mismatch: (parameters:Union[torch.Tensor, Iterable[torch.Tensor]], max_norm:float, norm_type:float=2.0) -> torch.Tensor vs (parameters, max_norm, norm_type=2)

Am i missing something here?

Hmm that doesn't look right. In your logs it still says:

WARNING:root:TPU has started up successfully with version pytorch-1.6

Can you try restart your runtime and also double check version with something like:

print(torch_xla.__version__)

Thanks. It works with torch==1.7 . Seems like it was running on torch==1.6 earlier

!pip uninstall torch -y
!pip install torch==1.6 

if it appears like.. "WARNING:root:TPU has started up successfully with version pytorch-1.6"

enjoy ...!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Clive2312 picture Clive2312  ยท  6Comments

cjolivier01 picture cjolivier01  ยท  7Comments

ogulcanogul picture ogulcanogul  ยท  5Comments

Arjuna197 picture Arjuna197  ยท  5Comments

butchland picture butchland  ยท  7Comments