From torch._six import container_abcs, string_classes, int_classes ImportError: cannot import name 'container_abcs' from 'torch._six' (/home/mona/anaconda3/envs/zephyr/lib/python3.9/site-packages/torch/

I get this error:

(zephyr) mona@ard-gpu-01:~/zephyr/python/zephyr$ python     --model_name pn2     --dataset_root ./data/ycb/matches_data_test/     --dataset_name ycbv     --dataset HSVD_diff_uv_norm     --no_valid_proj --no_valid_depth     --loss_cutoff log     --exp_name final     --resume_path ./ckpts/final_ycbv.ckpt
Traceback (most recent call last):
  File "/home/mona/zephyr/python/zephyr/", line 10, in <module>
    from zephyr.datasets import getDataloader
  File "/home/mona/zephyr/python/zephyr/datasets/", line 8, in <module>
    from zephyr.datasets.collate import default_collate
  File "/home/mona/zephyr/python/zephyr/datasets/", line 9, in <module>
    from torch._six import container_abcs, string_classes, int_classes
ImportError: cannot import name 'container_abcs' from 'torch._six' (/home/mona/anaconda3/envs/zephyr/lib/python3.9/site-packages/torch/

I saw this answer:

I was not sure where exactly I should add it so I added it here:
(zephyr) mona@ard-gpu-01:~/zephyr/python/zephyr$ vi /home/mona/zephyr/python/zephyr/

$ cat /home/mona/zephyr/python/zephyr/
import os
import numpy as np
import torch
import torch.cuda
import random

from pytorch_lightning import Trainer

from zephyr.models import getModel
from zephyr.datasets import getDataloader
from zephyr.options import getOptions, checkArgs

import as container_abcs

But it didn’t resolve the error. Do you know how I can fix it?

Here’s my env information:

(zephyr) mona@ard-gpu-01:~/zephyr$ python -m torch.utils.collect_env
Collecting environment information...
PyTorch version: 1.13.0+cu117
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.2 LTS (x86_64)
GCC version: (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
Clang version: 14.0.0-1ubuntu1
CMake version: version 3.22.1
Libc version: glibc-2.35

Python version: 3.9.16 (main, Mar  8 2023, 14:00:05)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.19.0-42-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 11.7.99
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3080 Laptop GPU
Nvidia driver version: 530.30.02
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.24.3
[pip3] pytorch-lightning==0.7.6
[pip3] torch==1.13.0+cu117
[pip3] torchmetrics==0.11.4
[pip3] torchtext==0.14.0
[pip3] torchvision==0.14.0+cu117
[conda] numpy                     1.24.3                   pypi_0    pypi
[conda] pytorch-lightning         0.7.6                    pypi_0    pypi
[conda] torch                     1.13.0+cu117             pypi_0    pypi
[conda] torchmetrics              0.11.4                   pypi_0    pypi
[conda] torchtext                 0.14.0                   pypi_0    pypi
[conda] torchvision               0.14.0+cu117             pypi_0    pypi

Here’s zephyr git repo: GitHub - r-pad/zephyr: Source code for ZePHyR: Zero-shot Pose Hypothesis Rating @ ICRA 2021
and the command I ran belongs to Test on YCB-V dataset

import torch
import re
#from torch._six import container_abcs, string_classes, int_classes
import as container_abcs

^^ the fix

(zephyr) mona@ard-gpu-01:~/zephyr/python/zephyr$ vi datasets/