Hi,
I’d like to train a model that relies on Detectron2. However, PyTorch Lightning is currently giving me an error when running import pytorch_lightning as pl
, after installing Detectron2. To reproduce (in Google Colab):
!pip install -q pyyaml==5.1
# workaround: install old version of pytorch since detectron2 hasn't released packages for pytorch 1.9 (issue: https://github.com/facebookresearch/detectron2/issues/3158)
!pip install -q torch==1.8.0+cu101 torchvision==0.9.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
# install detectron2 that matches pytorch 1.8
# See https://detectron2.readthedocs.io/tutorials/install.html for instructions
!pip install -q detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.8/index.html
!pip install pytorch_lightning
The error is:
ImportError Traceback (most recent call last)
<ipython-input-16-1941df7f6a6a> in <module>()
----> 1 import pytorch_lightning as pl
10 frames
/usr/local/lib/python3.7/dist-packages/pytorch_lightning/__init__.py in <module>()
18 _PROJECT_ROOT = os.path.dirname(_PACKAGE_ROOT)
19
---> 20 from pytorch_lightning import metrics # noqa: E402
21 from pytorch_lightning.callbacks import Callback # noqa: E402
22 from pytorch_lightning.core import LightningDataModule, LightningModule # noqa: E402
/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/__init__.py in <module>()
13 # limitations under the License.
14
---> 15 from pytorch_lightning.metrics.classification import ( # noqa: F401
16 Accuracy,
17 AUC,
/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/classification/__init__.py in <module>()
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
---> 14 from pytorch_lightning.metrics.classification.accuracy import Accuracy # noqa: F401
15 from pytorch_lightning.metrics.classification.auc import AUC # noqa: F401
16 from pytorch_lightning.metrics.classification.auroc import AUROC # noqa: F401
/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/classification/accuracy.py in <module>()
16 from torchmetrics import Accuracy as _Accuracy
17
---> 18 from pytorch_lightning.metrics.utils import deprecated_metrics
19
20
/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/utils.py in <module>()
27 from torchmetrics.utilities.distributed import reduce as _reduce
28
---> 29 from pytorch_lightning.utilities import rank_zero_deprecation
30 from pytorch_lightning.utilities.imports import (
31 _TORCHMETRICS_GREATER_EQUAL_0_3,
/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/__init__.py in <module>()
16 import numpy
17
---> 18 from pytorch_lightning.utilities.apply_func import move_data_to_device # noqa: F401
19 from pytorch_lightning.utilities.distributed import AllGatherGrad, rank_zero_info, rank_zero_only # noqa: F401
20 from pytorch_lightning.utilities.enums import ( # noqa: F401
/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/apply_func.py in <module>()
27
28 if _TORCHTEXT_AVAILABLE:
---> 29 if _compare_version("torchtext", operator.ge, "0.9.0"):
30 from torchtext.legacy.data import Batch
31 else:
/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/imports.py in _compare_version(package, op, version)
51 """
52 try:
---> 53 pkg = importlib.import_module(package)
54 except (ModuleNotFoundError, DistributionNotFound):
55 return False
/usr/lib/python3.7/importlib/__init__.py in import_module(name, package)
125 break
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
128
129
/usr/local/lib/python3.7/dist-packages/torchtext/__init__.py in <module>()
3 from . import datasets
4 from . import utils
----> 5 from . import vocab
6 from . import legacy
7
/usr/local/lib/python3.7/dist-packages/torchtext/vocab.py in <module>()
11 from typing import Dict, List, Optional, Iterable
12 from collections import Counter, OrderedDict
---> 13 from torchtext._torchtext import (
14 Vocab as VocabPybind,
15 )
ImportError: /usr/local/lib/python3.7/dist-packages/torchtext/_torchtext.so: undefined symbol: _ZN2at6detail10noopDeleteEPv
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
Apparently, it has to do with the fact that Detectron2 has no wheels yet for PyTorch 1.9.
My question is: can anyone provide me with a Google Colab in which one installs both Detectron2 and PyTorch Lightning that does not give an error when running import pytorch_lightning as pl
?