Problem with torchvision

idanZ: <p>Hi all, I am using pytorch 1.4 with latest installation of torchvision…<br>
I have encountered a problem with the VAE tutorial:</p>
<p>RuntimeError                              Traceback (most recent call last)<br>
 in <br>
----&gt; 1 import torchvision<br>
2 # from torchvision import transforms</p>
<p>~/virtualenv/lib/python3.6/site-packages/torchvision/<strong>init</strong>.py in <br>
1 import warnings<br>
2<br>
----&gt; 3 from torchvision import models<br>
4 from torchvision import datasets<br>
5 from torchvision import ops</p>
<p>~/virtualenv/lib/python3.6/site-packages/torchvision/models/<strong>init</strong>.py in <br>
10 from .shufflenetv2 import *<br>
11 from . import segmentation<br>
—&gt; 12 from . import detection<br>
13 from . import video<br>
14 from . import quantization</p>
<p>~/virtualenv/lib/python3.6/site-packages/torchvision/models/detection/<strong>init</strong>.py in <br>
----&gt; 1 from .faster_rcnn import *<br>
2 from .mask_rcnn import *<br>
3 from .keypoint_rcnn import *</p>
<p>~/virtualenv/lib/python3.6/site-packages/torchvision/models/detection/faster_rcnn.py in <br>
11<br>
12 from .generalized_rcnn import GeneralizedRCNN<br>
—&gt; 13 from .rpn import AnchorGenerator, RPNHead, RegionProposalNetwork<br>
14 from .roi_heads import RoIHeads<br>
15 from .transform import GeneralizedRCNNTransform</p>
<p>~/virtualenv/lib/python3.6/site-packages/torchvision/models/detection/rpn.py in <br>
9 from torchvision.ops import boxes as box_ops<br>
10<br>
—&gt; 11 from . import _utils as det_utils<br>
12 from .image_list import ImageList<br>
13</p>
<p>~/virtualenv/lib/python3.6/site-packages/torchvision/models/detection/_utils.py in <br>
17<br>
18 <span class="mention">@torch.jit.script</span><br>
—&gt; 19 class BalancedPositiveNegativeSampler(object):<br>
20     “”"<br>
21     This class samples batches, ensuring that they contain a fixed proportion of positives</p>
<p>~/virtualenv/lib/python3.6/site-packages/torch/jit/<strong>init</strong>.py in script(obj, optimize, _frames_up, _rcb)<br>
1217         use :func:<code>@torch.jit.ignore &lt;torch.jit.ignore&gt;</code>.<br>
1218<br>
-&gt; 1219         Example (an exported and ignored method in a module)::<br>
1220<br>
1221             import torch</p>
<p>~/virtualenv/lib/python3.6/site-packages/torch/jit/<strong>init</strong>.py in _compile_and_register_class(obj, rcb, qualified_name)<br>
1074<br>
1075 def _try_get_overloaded_fn(mod, field):<br>
-&gt; 1076     return mod._overloads.get(field, None) if isinstance(mod, ScriptModule) else None<br>
1077<br>
1078</p>
<p>RuntimeError: class ‘<strong>torch</strong>.torchvision.models.detection._utils.BalancedPositiveNegativeSampler’ already defined. (register_type at /pytorch/torch/csrc/jit/script/compilation_unit.h:166)<br>
frame <span class="hashtag">#0:</span> c10::Error::Error(c10::SourceLocation, std::string const&amp;) + 0x33 (0x7f66fa4cc813 in /home/octopus/virtualenv/lib/python3.6/site-packages/torch/lib/libc10.so)<br>
frame <span class="hashtag">#1:</span>  + 0x5a2539 (0x7f6742742539 in /home/octopus/virtualenv/lib/python3.6/site-packages/torch/lib/libtorch_python.so)<br>
frame <span class="hashtag">#2:</span>  + 0x589e4e (0x7f6742729e4e in /home/octopus/virtualenv/lib/python3.6/site-packages/torch/lib/libtorch_python.so)<br>
frame <span class="hashtag">#3:</span>  + 0x58b123 (0x7f674272b123 in /home/octopus/virtualenv/lib/python3.6/site-packages/torch/lib/libtorch_python.so)<br>
frame <span class="hashtag">#4:</span>  + 0x2110f4 (0x7f67423b10f4 in /home/octopus/virtualenv/lib/python3.6/site-packages/torch/lib/libtorch_python.so)<br>
frame <span class="hashtag">#5:</span> _PyCFunction_FastCallKeywords + 0x1eb (0x522f1b in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#6:</span> /home/octopus/virtualenv/bin/python3() [0x57c9b9]<br>
frame <span class="hashtag">#7:</span> _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#8:</span> /home/octopus/virtualenv/bin/python3() [0x57da4d]<br>
frame <span class="hashtag">#9:</span> /home/octopus/virtualenv/bin/python3() [0x57ca9c]<br>
frame <span class="hashtag">#10:</span> _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#11:</span> /home/octopus/virtualenv/bin/python3() [0x574417]<br>
frame <span class="hashtag">#12:</span> /home/octopus/virtualenv/bin/python3() [0x57db0b]<br>
frame <span class="hashtag">#13:</span> /home/octopus/virtualenv/bin/python3() [0x57ca9c]<br>
frame <span class="hashtag">#14:</span> _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#15:</span> /home/octopus/virtualenv/bin/python3() [0x574417]<br>
frame <span class="hashtag">#16:</span> PyEval_EvalCode + 0x23 (0x574193 in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#17:</span> /home/octopus/virtualenv/bin/python3() [0x572221]<br>
frame <span class="hashtag">#18:</span> PyCFunction_Call + 0x126 (0x5234f6 in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#19:</span> _PyEval_EvalFrameDefault + 0x5c3f (0x57ab5f in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#20:</span> /home/octopus/virtualenv/bin/python3() [0x574417]<br>
frame <span class="hashtag">#21:</span> /home/octopus/virtualenv/bin/python3() [0x57db0b]<br>
frame <span class="hashtag">#22:</span> /home/octopus/virtualenv/bin/python3() [0x57ca9c]<br>
frame <span class="hashtag">#23:</span> _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#24:</span> /home/octopus/virtualenv/bin/python3() [0x57da4d]<br>
frame <span class="hashtag">#25:</span> /home/octopus/virtualenv/bin/python3() [0x57ca9c]<br>
frame <span class="hashtag">#26:</span> _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#27:</span> /home/octopus/virtualenv/bin/python3() [0x57da4d]<br>
frame <span class="hashtag">#28:</span> /home/octopus/virtualenv/bin/python3() [0x57ca9c]<br>
frame <span class="hashtag">#29:</span> _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#30:</span> /home/octopus/virtualenv/bin/python3() [0x57da4d]<br>
frame <span class="hashtag">#31:</span> /home/octopus/virtualenv/bin/python3() [0x57ca9c]<br>
frame <span class="hashtag">#32:</span> _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#33:</span> _PyFunction_FastCallDict + 0x133 (0x57e323 in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#34:</span> _PyObject_CallMethodIdObjArgs + 0x270 (0x4e8d20 in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#35:</span> PyImport_ImportModuleLevelObject + 0x5d0 (0x591ce0 in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#36:</span> /home/octopus/virtualenv/bin/python3() [0x572574]<br>
frame <span class="hashtag">#37:</span> PyCFunction_Call + 0xc6 (0x523496 in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#38:</span> _PyEval_EvalFrameDefault + 0x5c3f (0x57ab5f in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#39:</span> /home/octopus/virtualenv/bin/python3() [0x574417]<br>
frame <span class="hashtag">#40:</span> /home/octopus/virtualenv/bin/python3() [0x57db0b]<br>
frame <span class="hashtag">#41:</span> /home/octopus/virtualenv/bin/python3() [0x57ca9c]<br>
frame <span class="hashtag">#42:</span> _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#43:</span> /home/octopus/virtualenv/bin/python3() [0x5747d6]<br>
frame <span class="hashtag">#44:</span> _PyFunction_FastCallDict + 0x1da (0x57e3ca in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#45:</span> _PyObject_CallMethodIdObjArgs + 0x270 (0x4e8d20 in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#46:</span> PyImport_ImportModuleLevelObject + 0x205 (0x591915 in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#47:</span> _PyEval_EvalFrameDefault + 0x2ae5 (0x577a05 in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#48:</span> /home/octopus/virtualenv/bin/python3() [0x574417]<br>
frame <span class="hashtag">#49:</span> PyEval_EvalCode + 0x23 (0x574193 in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#50:</span> /home/octopus/virtualenv/bin/python3() [0x572221]<br>
frame <span class="hashtag">#51:</span> PyCFunction_Call + 0x126 (0x5234f6 in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#52:</span> _PyEval_EvalFrameDefault + 0x5c3f (0x57ab5f in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#53:</span> /home/octopus/virtualenv/bin/python3() [0x574417]<br>
frame <span class="hashtag">#54:</span> /home/octopus/virtualenv/bin/python3() [0x57db0b]<br>
frame <span class="hashtag">#55:</span> /home/octopus/virtualenv/bin/python3() [0x57ca9c]<br>
frame <span class="hashtag">#56:</span> _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#57:</span> /home/octopus/virtualenv/bin/python3() [0x57da4d]<br>
frame <span class="hashtag">#58:</span> /home/octopus/virtualenv/bin/python3() [0x57ca9c]<br>
frame <span class="hashtag">#59:</span> _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#60:</span> /home/octopus/virtualenv/bin/python3() [0x57da4d]<br>
frame <span class="hashtag">#61:</span> /home/octopus/virtualenv/bin/python3() [0x57ca9c]<br>
frame <span class="hashtag">#62:</span> _PyEval_EvalFrameDefault + 0x45e (0x57537e in /home/octopus/virtualenv/bin/python3)<br>
frame <span class="hashtag">#63:</span> /home/octopus/virtualenv/bin/python3() [0x57da4d]</p>

Dipam_Vasani: <p>I’m facing the same issue, were you able to solve it?</p>

Pelk: <p>Hi, I got the same issue <img src="https://discuss.pytorch.org/images/emoji/apple/confused.png?v=9" title=":confused:" class="emoji" alt=":confused:"></p>

CuiKaiChina: <p>Maybe you should notice the CUDA of  your computer ,which must  be correspond with the version of pytorch! So please check it  and choose the right version of pytorch!  I hope my advise maybe usefull.Good luck!</p>

ptrblck: <p>If you install the binaries with <code>cudatoolkit</code>, your local CUDA installation won’t be used.</p>
<p><a class="mention" href="/u/idanz">@idanZ</a>, <a class="mention" href="/u/dipam_vasani">@Dipam_Vasani</a>, <a class="mention" href="/u/pelk">@Pelk</a><br>
Could you update to the latest stable versions and create an issue on GitHub, if you are still facing this problem.</p>
<p>CC <a class="mention" href="/u/fmassa">@fmassa</a> in case you’ve seen this error before.</p>