Problem with torchvision

Hi all, I am using pytorch 1.4 with latest installation of torchvision…
I have encountered a problem with the VAE tutorial:

RuntimeError Traceback (most recent call last)
in
----> 1 import torchvision
2 # from torchvision import transforms

~/virtualenv/lib/python3.6/site-packages/torchvision/init.py in
1 import warnings
2
----> 3 from torchvision import models
4 from torchvision import datasets
5 from torchvision import ops

~/virtualenv/lib/python3.6/site-packages/torchvision/models/init.py in
10 from .shufflenetv2 import *
11 from . import segmentation
—> 12 from . import detection
13 from . import video
14 from . import quantization

~/virtualenv/lib/python3.6/site-packages/torchvision/models/detection/init.py in
----> 1 from .faster_rcnn import *
2 from .mask_rcnn import *
3 from .keypoint_rcnn import *

~/virtualenv/lib/python3.6/site-packages/torchvision/models/detection/faster_rcnn.py in
11
12 from .generalized_rcnn import GeneralizedRCNN
—> 13 from .rpn import AnchorGenerator, RPNHead, RegionProposalNetwork
14 from .roi_heads import RoIHeads
15 from .transform import GeneralizedRCNNTransform

~/virtualenv/lib/python3.6/site-packages/torchvision/models/detection/rpn.py in
9 from torchvision.ops import boxes as box_ops
10
—> 11 from . import _utils as det_utils
12 from .image_list import ImageList
13

~/virtualenv/lib/python3.6/site-packages/torchvision/models/detection/_utils.py in
17
18 @torch.jit.script
—> 19 class BalancedPositiveNegativeSampler(object):
20 “”"
21 This class samples batches, ensuring that they contain a fixed proportion of positives

~/virtualenv/lib/python3.6/site-packages/torch/jit/init.py in script(obj, optimize, _frames_up, _rcb)
1217 use :func:@torch.jit.ignore <torch.jit.ignore>.
1218
-> 1219 Example (an exported and ignored method in a module)::
1220
1221 import torch

~/virtualenv/lib/python3.6/site-packages/torch/jit/init.py in _compile_and_register_class(obj, rcb, qualified_name)
1074
1075 def _try_get_overloaded_fn(mod, field):
-> 1076 return mod._overloads.get(field, None) if isinstance(mod, ScriptModule) else None
1077
1078

RuntimeError: class ‘torch.torchvision.models.detection._utils.BalancedPositiveNegativeSampler’ already defined. (register_type at /pytorch/torch/csrc/jit/script/compilation_unit.h:166)
frame #0: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x33 (0x7f66fa4cc813 in /home/octopus/virtualenv/lib/python3.6/site-packages/torch/lib/libc10.so)
frame #1: + 0x5a2539 (0x7f6742742539 in /home/octopus/virtualenv/lib/python3.6/site-packages/torch/lib/libtorch_python.so)
frame #2: + 0x589e4e (0x7f6742729e4e in /home/octopus/virtualenv/lib/python3.6/site-packages/torch/lib/libtorch_python.so)
frame #3: + 0x58b123 (0x7f674272b123 in /home/octopus/virtualenv/lib/python3.6/site-packages/torch/lib/libtorch_python.so)
frame #4: + 0x2110f4 (0x7f67423b10f4 in /home/octopus/virtualenv/lib/python3.6/site-packages/torch/lib/libtorch_python.so)
frame #5: _PyCFunction_FastCallKeywords + 0x1eb (0x522f1b in /home/octopus/virtualenv/bin/python3)
frame #6: /home/octopus/virtualenv/bin/python3() [0x57c9b9]
frame #7: _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)
frame #8: /home/octopus/virtualenv/bin/python3() [0x57da4d]
frame #9: /home/octopus/virtualenv/bin/python3() [0x57ca9c]
frame #10: _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)
frame #11: /home/octopus/virtualenv/bin/python3() [0x574417]
frame #12: /home/octopus/virtualenv/bin/python3() [0x57db0b]
frame #13: /home/octopus/virtualenv/bin/python3() [0x57ca9c]
frame #14: _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)
frame #15: /home/octopus/virtualenv/bin/python3() [0x574417]
frame #16: PyEval_EvalCode + 0x23 (0x574193 in /home/octopus/virtualenv/bin/python3)
frame #17: /home/octopus/virtualenv/bin/python3() [0x572221]
frame #18: PyCFunction_Call + 0x126 (0x5234f6 in /home/octopus/virtualenv/bin/python3)
frame #19: _PyEval_EvalFrameDefault + 0x5c3f (0x57ab5f in /home/octopus/virtualenv/bin/python3)
frame #20: /home/octopus/virtualenv/bin/python3() [0x574417]
frame #21: /home/octopus/virtualenv/bin/python3() [0x57db0b]
frame #22: /home/octopus/virtualenv/bin/python3() [0x57ca9c]
frame #23: _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)
frame #24: /home/octopus/virtualenv/bin/python3() [0x57da4d]
frame #25: /home/octopus/virtualenv/bin/python3() [0x57ca9c]
frame #26: _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)
frame #27: /home/octopus/virtualenv/bin/python3() [0x57da4d]
frame #28: /home/octopus/virtualenv/bin/python3() [0x57ca9c]
frame #29: _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)
frame #30: /home/octopus/virtualenv/bin/python3() [0x57da4d]
frame #31: /home/octopus/virtualenv/bin/python3() [0x57ca9c]
frame #32: _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)
frame #33: _PyFunction_FastCallDict + 0x133 (0x57e323 in /home/octopus/virtualenv/bin/python3)
frame #34: _PyObject_CallMethodIdObjArgs + 0x270 (0x4e8d20 in /home/octopus/virtualenv/bin/python3)
frame #35: PyImport_ImportModuleLevelObject + 0x5d0 (0x591ce0 in /home/octopus/virtualenv/bin/python3)
frame #36: /home/octopus/virtualenv/bin/python3() [0x572574]
frame #37: PyCFunction_Call + 0xc6 (0x523496 in /home/octopus/virtualenv/bin/python3)
frame #38: _PyEval_EvalFrameDefault + 0x5c3f (0x57ab5f in /home/octopus/virtualenv/bin/python3)
frame #39: /home/octopus/virtualenv/bin/python3() [0x574417]
frame #40: /home/octopus/virtualenv/bin/python3() [0x57db0b]
frame #41: /home/octopus/virtualenv/bin/python3() [0x57ca9c]
frame #42: _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)
frame #43: /home/octopus/virtualenv/bin/python3() [0x5747d6]
frame #44: _PyFunction_FastCallDict + 0x1da (0x57e3ca in /home/octopus/virtualenv/bin/python3)
frame #45: _PyObject_CallMethodIdObjArgs + 0x270 (0x4e8d20 in /home/octopus/virtualenv/bin/python3)
frame #46: PyImport_ImportModuleLevelObject + 0x205 (0x591915 in /home/octopus/virtualenv/bin/python3)
frame #47: _PyEval_EvalFrameDefault + 0x2ae5 (0x577a05 in /home/octopus/virtualenv/bin/python3)
frame #48: /home/octopus/virtualenv/bin/python3() [0x574417]
frame #49: PyEval_EvalCode + 0x23 (0x574193 in /home/octopus/virtualenv/bin/python3)
frame #50: /home/octopus/virtualenv/bin/python3() [0x572221]
frame #51: PyCFunction_Call + 0x126 (0x5234f6 in /home/octopus/virtualenv/bin/python3)
frame #52: _PyEval_EvalFrameDefault + 0x5c3f (0x57ab5f in /home/octopus/virtualenv/bin/python3)
frame #53: /home/octopus/virtualenv/bin/python3() [0x574417]
frame #54: /home/octopus/virtualenv/bin/python3() [0x57db0b]
frame #55: /home/octopus/virtualenv/bin/python3() [0x57ca9c]
frame #56: _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)
frame #57: /home/octopus/virtualenv/bin/python3() [0x57da4d]
frame #58: /home/octopus/virtualenv/bin/python3() [0x57ca9c]
frame #59: _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)
frame #60: /home/octopus/virtualenv/bin/python3() [0x57da4d]
frame #61: /home/octopus/virtualenv/bin/python3() [0x57ca9c]
frame #62: _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)
frame #63: /home/octopus/virtualenv/bin/python3() [0x57da4d]

I’m facing the same issue, were you able to solve it?

Hi, I got the same issue :confused: