Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'torchvision' has no attribute 'datasets' #186

Open
PrimoWW opened this issue Oct 17, 2022 · 10 comments
Open

AttributeError: module 'torchvision' has no attribute 'datasets' #186

PrimoWW opened this issue Oct 17, 2022 · 10 comments

Comments

@PrimoWW
Copy link

PrimoWW commented Oct 17, 2022

❓ Questions and Help

hello, thank you for the great job.
when i run the command bash train.sh Language_VG_Uniter
a problem happened below:

Traceback (most recent call last):
  File "tools/relation_train_net.py", line 19, in <module>
    from maskrcnn_benchmark.data import make_data_loader
  File "/home/liujingwei/icme/sgg_from_nls/maskrcnn_benchmark/data/__init__.py", line 2, in <module>
    from .build import make_data_loader, get_dataset_statistics
  File "/home/liujingwei/icme/sgg_from_nls/maskrcnn_benchmark/data/build.py", line 14, in <module>
    from . import datasets as D
  File "/home/liujingwei/icme/sgg_from_nls/maskrcnn_benchmark/data/datasets/__init__.py", line 2, in <module>
    from .coco import COCODataset
  File "/home/liujingwei/icme/sgg_from_nls/maskrcnn_benchmark/data/datasets/coco.py", line 39, in <module>
    class COCODataset(torchvision.datasets.coco.CocoDetection):
AttributeError: module 'torchvision' has no attribute 'datasets'

I dont know if the torchvision is wrong or something happened.

@Infinitywxh
Copy link

Hi, have you managed to fix this problem? I have the same issue here.

@farahFif
Copy link

I have the same problem, did you find a solution?

@explorer-shy
Copy link

I have the same problem, I had tried many versions of torchvisions, but the problem remains. Did you find a solution?

@farahFif
Copy link

farahFif commented Feb 8, 2023

I solved this problem, first by having the right torch, torchvision and torch audio. Then the mistake I made is to put all repos in one folder which created some sort of conflict. So make sure that apex and cocoapi are cloned in different folder than scene graph.

@David1-git
Copy link

I solved this problem, first by having the right torch, torchvision and torch audio. Then the mistake I made is to put all repos in one folder which created some sort of conflict. So make sure that apex and cocoapi are cloned in different folder than scene graph.

Can you tell me more about how you solved it

@explorer-shy
Copy link

I solved this problem, in the file https://github.com/KaihuaTang/Scene-Graph-Benchmark.pytorch/blob/master/INSTALL.md,the author wrote down this code

# install PyTorch Detection
cd $INSTALL_DIR
git clone https://github.com/KaihuaTang/Scene-Graph-Benchmark.pytorch.git
cd scene-graph-benchmark

# the following will install the lib with
# symbolic links, so that you can modify
# the files if you want and won't need to
# re-build it
python setup.py build develop

However, I misunderstood it. I mistakenly thought that it didn't matter to the project whether or not to run the code python setup.py build develop.

So, if you meet the problem "AttributeError: module 'torchvision' has no attribute 'datasets'" , just don't forget to run this code python setup.py build develop and you will solve it.

Also, if you change GPU after you build this project ,you need to delete the directory build and file maskrcnn_benchmark/***.so, and then re-build it to develop these files.

By the way, I also sovled a problem I met. The problem is "ImportError: cannot import name 'amp' from 'apex' (unknown location)" , you can follow this guide https://stackoverflow.com/questions/70547501/importerror-cannot-import-name-amp-from-apex-unknown-location-jupyter-la to solve this problem I mentioned.

@zhangce01
Copy link

zhangce01 commented Sep 12, 2023

Recently I have the same problem. I have tried the methods mentioned above and still cannot solve it. It seems that the codes import the wrong torchvision package:
<module 'torchvision' from '/home/xxx/.cache/torch_extensions/py39_cu116/torchvision/torchvision.so'>.
Could someone share some useful solutions? I would deeply appreciate it.

@lalalisa666
Copy link

Recently I have the same problem. I have tried the methods mentioned above and still cannot solve it. It seems that the codes import the wrong torchvision package: <module 'torchvision' from '/home/xxx/.cache/torch_extensions/py39_cu116/torchvision/torchvision.so'>. Could someone share some useful solutions? I would deeply appreciate it.

hi, I have met the same problem. Have you solved it?

@draym28
Copy link

draym28 commented Apr 2, 2024

I solved this problem, in the file https://github.com/KaihuaTang/Scene-Graph-Benchmark.pytorch/blob/master/INSTALL.md,the author wrote down this code

# install PyTorch Detection
cd $INSTALL_DIR
git clone https://github.com/KaihuaTang/Scene-Graph-Benchmark.pytorch.git
cd scene-graph-benchmark

# the following will install the lib with
# symbolic links, so that you can modify
# the files if you want and won't need to
# re-build it
python setup.py build develop

However, I misunderstood it. I mistakenly thought that it didn't matter to the project whether or not to run the code python setup.py build develop.

So, if you meet the problem "AttributeError: module 'torchvision' has no attribute 'datasets'" , just don't forget to run this code python setup.py build develop and you will solve it.

Also, if you change GPU after you build this project ,you need to delete the directory build and file maskrcnn_benchmark/***.so, and then re-build it to develop these files.

By the way, I also sovled a problem I met. The problem is "ImportError: cannot import name 'amp' from 'apex' (unknown location)" , you can follow this guide https://stackoverflow.com/questions/70547501/importerror-cannot-import-name-amp-from-apex-unknown-location-jupyter-la to solve this problem I mentioned.

I did this, but the problem still happened. This made me crazy.

@QgZhan
Copy link

QgZhan commented Oct 19, 2024

Recently I have the same problem. I have tried the methods mentioned above and still cannot solve it. It seems that the codes import the wrong torchvision package: <module 'torchvision' from '/home/xxx/.cache/torch_extensions/py39_cu116/torchvision/torchvision.so'>. Could someone share some useful solutions? I would deeply appreciate it.

hi, I have met the same problem. Have you solved it?

I solved this problem. In this file

, the 32 line name the saved C_extensions as 'torchvision', which is conflicted with the official torchvision package.
I modified the 'torchvision' in the 32 line to 'nmstorchvision'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants