astra-vision / MonoScene

[CVPR 2022] "MonoScene: Monocular 3D Semantic Scene Completion": 3D Semantic Occupancy Prediction from a single image

Home Page:https://astra-vision.github.io/MonoScene/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data'

LittlePotatoChip opened this issue · comments

there is something wrong with my machine and I reinstall my ubuntu. I re-gitclone the code and just keep the data.but when I follow the readme to do installation,it print:

(monoscene) potato@ubuntu-X299-UD4-Pro:/workplace/MonoScene$ pip install -e ./
Obtaining file:///home/potato/workplace/MonoScene
Installing collected packages: monoscene
Running setup.py develop for monoscene
Successfully installed monoscene-0.0.0
(monoscene) potato@ubuntu-X299-UD4-Pro:
/workplace/MonoScene$ python monoscene/scripts/train_monoscene.py dataset=kitti enable_log=true kitti_root=$KITTI_ROOT kitti_preprocess_root=$KITTI_PREPROCESS kitti_logdir=$KITTI_LOG n_gpus=1 batch_size=1 sem_scal_loss=False
Traceback (most recent call last):
File "monoscene/scripts/train_monoscene.py", line 1, in
from monoscene.data.semantic_kitti.kitti_dm import KittiDataModule
File "/home/potato/workplace/MonoScene/monoscene/data/semantic_kitti/kitti_dm.py", line 3, in
import pytorch_lightning as pl
File "/home/potato/anaconda3/envs/monoscene/lib/python3.7/site-packages/pytorch_lightning/init.py", line 20, in
from pytorch_lightning import metrics # noqa: E402
File "/home/potato/anaconda3/envs/monoscene/lib/python3.7/site-packages/pytorch_lightning/metrics/init.py", line 15, in
from pytorch_lightning.metrics.classification import ( # noqa: F401
File "/home/potato/anaconda3/envs/monoscene/lib/python3.7/site-packages/pytorch_lightning/metrics/classification/init.py", line 14, in
from pytorch_lightning.metrics.classification.accuracy import Accuracy # noqa: F401
File "/home/potato/anaconda3/envs/monoscene/lib/python3.7/site-packages/pytorch_lightning/metrics/classification/accuracy.py", line 18, in
from pytorch_lightning.metrics.utils import deprecated_metrics, void
File "/home/potato/anaconda3/envs/monoscene/lib/python3.7/site-packages/pytorch_lightning/metrics/utils.py", line 22, in
from torchmetrics.utilities.data import get_num_classes as _get_num_classes
ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data' (/home/potato/anaconda3/envs/monoscene/lib/python3.7/site-packages/torchmetrics/utilities/data.py)

I think maybe that "Successfully installed monoscene-0.0.0" ,the building process make wrongs?

This is the error in pytorch-lightning version. Could you verify that your pytorch-lightning version is "pytorch-lightning==1.4.0rc0"?

This is the error in pytorch-lightning version. Could you verify that your pytorch-lightning version is "pytorch-lightning==1.4.0rc0"?

yes,I use the "pip install -r requirements.txt"

Could you try this? NVIDIA/DeepLearningExamples#1113 (comment)

I tried to reinstall the pytorch-lightning of another version,but it just printed:
RuntimeError: SpatialClassNLLCriterion_updateOutput does not have a deterministic implementation, but you set 'torch.use_deterministic_algorithms(True)'. You can turn off determinism just for this operation if that's acceptable for your application. You can also file an issue at https://github.com/pytorch/pytorch/issues to help us prioritize adding deterministic support for this operation.

You can set deterministic to False on lines 145 and 159 in the following file
https://github.com/cv-rits/MonoScene/blob/master/monoscene/scripts/train_monoscene.py#L159

You can set deterministic to False on lines 145 and 159 in the following file https://github.com/cv-rits/MonoScene/blob/master/monoscene/scripts/train_monoscene.py#L159

it works,thanks

ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data' (C:\ProgramData\anaconda3\Lib\site-packages\torchmetrics\utilities\data.py)

@Nikithareddy2201 yes! i'm facing the same problem ,Have You Ever solve it ?

I think the error is because of newer torchmetrics version, could you downgrade it to 0.6.0 with
pip install torchmetrics==0.6.0