question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get AttributeError: type object 'object' has no attribute 'SUM'

See original GitHub issue

Bug description

Getting this error:

self, tensor: Tensor, group: Optional[Any] = None, reduce_op: Optional[Union[ReduceOp, str]] = ReduceOp.SUM

E AttributeError: type object ‘object’ has no attribute ‘SUM’

How to reproduce the bug

Install pyg and run pytest.

Error messages and logs

test/conftest.py:7: in <module>
    from torch_geometric.data import Dataset
torch_geometric/__init__.py:4: in <module>
    import torch_geometric.data
torch_geometric/data/__init__.py:7: in <module>
    from .lightning_datamodule import (
torch_geometric/data/lightning_datamodule.py:24: in <module>
    from pytorch_lightning import LightningDataModule as PLLightningDataModule
../../../opt/anaconda3/envs/sparse_tensor/lib/python3.8/site-packages/pytorch_lightning/__init__.py:35: in <module>
    from pytorch_lightning.callbacks import Callback  # noqa: E402
../../../opt/anaconda3/envs/sparse_tensor/lib/python3.8/site-packages/pytorch_lightning/callbacks/__init__.py:28: in <module>
    from pytorch_lightning.callbacks.pruning import ModelPruning
../../../opt/anaconda3/envs/sparse_tensor/lib/python3.8/site-packages/pytorch_lightning/callbacks/pruning.py:31: in <module>
    from pytorch_lightning.core.module import LightningModule
../../../opt/anaconda3/envs/sparse_tensor/lib/python3.8/site-packages/pytorch_lightning/core/__init__.py:16: in <module>
    from pytorch_lightning.core.module import LightningModule
../../../opt/anaconda3/envs/sparse_tensor/lib/python3.8/site-packages/pytorch_lightning/core/module.py:47: in <module>
    from pytorch_lightning.trainer.connectors.logger_connector.fx_validator import _FxValidator
../../../opt/anaconda3/envs/sparse_tensor/lib/python3.8/site-packages/pytorch_lightning/trainer/__init__.py:17: in <module>
    from pytorch_lightning.trainer.trainer import Trainer
../../../opt/anaconda3/envs/sparse_tensor/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py:57: in <module>
    from pytorch_lightning.loops import PredictionLoop, TrainingEpochLoop
../../../opt/anaconda3/envs/sparse_tensor/lib/python3.8/site-packages/pytorch_lightning/loops/__init__.py:15: in <module>
    from pytorch_lightning.loops.batch import TrainingBatchLoop  # noqa: F401
../../../opt/anaconda3/envs/sparse_tensor/lib/python3.8/site-packages/pytorch_lightning/loops/batch/__init__.py:15: in <module>
    from pytorch_lightning.loops.batch.training_batch_loop import TrainingBatchLoop  # noqa: F401
../../../opt/anaconda3/envs/sparse_tensor/lib/python3.8/site-packages/pytorch_lightning/loops/batch/training_batch_loop.py:20: in <module>
    from pytorch_lightning.loops.optimization.manual_loop import _OUTPUTS_TYPE as _MANUAL_LOOP_OUTPUTS_TYPE
../../../opt/anaconda3/envs/sparse_tensor/lib/python3.8/site-packages/pytorch_lightning/loops/optimization/__init__.py:15: in <module>
    from pytorch_lightning.loops.optimization.manual_loop import ManualOptimization  # noqa: F401
../../../opt/anaconda3/envs/sparse_tensor/lib/python3.8/site-packages/pytorch_lightning/loops/optimization/manual_loop.py:23: in <module>
    from pytorch_lightning.loops.utilities import _build_training_step_kwargs, _extract_hiddens
../../../opt/anaconda3/envs/sparse_tensor/lib/python3.8/site-packages/pytorch_lightning/loops/utilities.py:29: in <module>
    from pytorch_lightning.strategies.parallel import ParallelStrategy
../../../opt/anaconda3/envs/sparse_tensor/lib/python3.8/site-packages/pytorch_lightning/strategies/__init__.py:16: in <module>
    from pytorch_lightning.strategies.colossalai import ColossalAIStrategy  # noqa: F401
../../../opt/anaconda3/envs/sparse_tensor/lib/python3.8/site-packages/pytorch_lightning/strategies/colossalai.py:48: in <module>
    class ColossalAIStrategy(DDPStrategy):
../../../opt/anaconda3/envs/sparse_tensor/lib/python3.8/site-packages/pytorch_lightning/strategies/colossalai.py:435: in ColossalAIStrategy
    self, tensor: Tensor, group: Optional[Any] = None, reduce_op: Optional[Union[ReduceOp, str]] = ReduceOp.SUM
E   AttributeError: type object 'object' has no attribute 'SUM'

Environment


#- Lightning Component (e.g. Trainer, LightningModule, LightningApp, LightningWork, LightningFlow):
#- PyTorch Lightning Version (e.g., 1.5.0):
#- Lightning App Version (e.g., 0.5.2):
#- PyTorch Version (e.g., 1.10):
#- Python version (e.g., 3.9):
#- OS (e.g., Linux):
#- CUDA/cuDNN version:
#- GPU models and configuration:
#- How you installed Lightning(`conda`, `pip`, source):
#- Running environment of LightningApp (e.g. local, cloud):

More info

No response

cc @tchaton @rohitgr7

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
awaelchlicommented, Nov 4, 2022

This linked PR should fix this issue. Thanks for reporting! This bug affects all users with a torch installation where torch.distributed.is_available() returns False.

1reaction
awaelchlicommented, Nov 4, 2022

I have already investigated in that direction. One could change it in the CI like you said. For now, I pretend distributed is not available. What I have added so far is this regression test.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'function' object has no attribute 'sum' pandas
There is a pandas.DataFrame.count method, which is shadowing the name of your column. This is why you're getting this error message - the ......
Read more >
'function' object has no attribute 'sum' : r/Python - Reddit
You have to use () to "call" the function and have it return a value. The value will be a boolean which has...
Read more >
My code passes, but it doesn't actually work. - Codecademy
The error 'list' object has no attribute 'sum' suggests the parser does not like your use of object.sum(). I think it is trying...
Read more >
AttributeError: 'BooleanArray' object has no attribute 'sum ...
Caused an "AttributeError: 'BooleanArray' object has no attribute 'sum'" following some global ananconda update. Changed the line to
Read more >
AttributeError: 'function' object has no attribute 'sum' pandas ...
There is a pandas.DataFrame.count method, which is shadowing the name of your column. This is why you're getting this error message - the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found