Pretrained model load error

wzhings: <p>Hi all,<br>
I am a beginner of PyTorch and try to master the PyTorch library.<br>
I met a problem about pretrained model loading with the following codes:</p>
<pre><code class="lang-auto">import torchvision.models as models
resnet18 = models.resnet18(pretrained=True)
</code></pre>
<p>The error information is listed as follows:</p>
<pre><code class="lang-auto">Downloading: "https://download.pytorch.org/models/resnet18-5c106cde.pth" to /home/xxx/.cache/torch/checkpoints/resnet18-5c106cde.pth

---------------------------------------------------------------------------
TqdmKeyError                              Traceback (most recent call last)
&lt;ipython-input-1-ca5a1cdda949&gt; in &lt;module&gt;
      1 import torchvision.models as models
----&gt; 2 resnet18 = models.resnet18(pretrained=True)
      3 #resnet18 = models.resnet18()

~/.conda/envs/wzh/lib/python3.6/site-packages/torchvision/models/resnet.py in resnet18(pretrained, progress, **kwargs)
    229     """
    230     return _resnet('resnet18', BasicBlock, [2, 2, 2, 2], pretrained, progress,
--&gt; 231                    **kwargs)
    232 
    233 

~/.conda/envs/wzh/lib/python3.6/site-packages/torchvision/models/resnet.py in _resnet(arch, block, layers, pretrained, progress, **kwargs)
    215     if pretrained:
    216         state_dict = load_state_dict_from_url(model_urls[arch],
--&gt; 217                                               progress=progress)
    218         model.load_state_dict(state_dict)
    219     return model

~/.conda/envs/wzh/lib/python3.6/site-packages/torch/hub.py in load_state_dict_from_url(url, model_dir, map_location, progress, check_hash)
    483         sys.stderr.write('Downloading: "{}" to {}\n'.format(url, cached_file))
    484         hash_prefix = HASH_REGEX.search(filename).group(1) if check_hash else None
--&gt; 485         download_url_to_file(url, cached_file, hash_prefix, progress=progress)
    486 
    487     # Note: extractall() defaults to overwrite file if exists. No need to clean up beforehand.

~/.conda/envs/wzh/lib/python3.6/site-packages/torch/hub.py in download_url_to_file(url, dst, hash_prefix, progress)
    402             sha256 = hashlib.sha256()
    403         with tqdm(total=file_size, disable=not progress,
--&gt; 404                   unit='B', unit_scale=True, unit_divisor=1024) as pbar:
    405             while True:
    406                 buffer = u.read(8192)

~/.local/lib/python3.6/site-packages/tqdm/_tqdm.py in __init__(self, iterable, desc, total, leave, file, ncols, mininterval, maxinterval, miniters, ascii, disable, unit, unit_scale, dynamic_ncols, smoothing, bar_format, initial, position, postfix, gui, **kwargs)
    660 """, fp_write=getattr(file, 'write', sys.stderr.write))
    661                 if "nested" in kwargs else
--&gt; 662                 TqdmKeyError("Unknown argument(s): " + str(kwargs)))
    663 
    664         # Preprocess the arguments

TqdmKeyError: "Unknown argument(s): {'unit_divisor': 1024}"

</code></pre>
<p>If I removed “<strong>pretrained=True</strong>”, the codes work normally. I tried to google the error information, but no useful information returned. Could you please help me about this error?  Thanks</p>

ptrblck: <p>It seems <code>tqdm</code> doesn’t recognize the <code>unit_divisor</code> argument.<br>
Did you install another version (or an older one) in your environment?</p>

wzhings: <p>No, I just installed</p>
<p>Pytorch with version = 1.3.1,<br>
torchvision = 0.4.2,<br>
python = 3.6.9,<br>
cudatoolkit = 10.1.243.</p>
<p>But I will try an older version such as Pytorch 1.2 and see.</p>

wzhings: <aside class="quote no-group" data-username="wzhings" data-post="1" data-topic="65932">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/w/f19dbf/48.png" class="avatar"> wzhings:</div>
<blockquote>
<p>import torchvision.models as models resnet18 = models.resnet18(pretrained=True)</p>
</blockquote>
</aside>
<p>pytorch 1.2.0 will cause this error too.<br>
But pytorch 1.1.0 and torchvision 0.3.0 do not trigger this error.</p>

ptrblck: <p>Could you print the <code>tqdm</code> version in your current environment please?<br>
Downgrading PyTorch to <code>1.1.0</code> is not the right solution to this problem, and I would like to figure out, what’s going on.</p>

wzhings: <p>My current tqdm version is <strong>4.11.2</strong><br>
Hope it helps.</p>

ptrblck: <p>Could you update <code>tqdm</code> to <code>4.36.1</code> or a later version? (The latest seems to be <code>4.41.1</code>).</p>

l2silver: <p>I’ve got the same issue. tqdm 4.36.1 . Weird thing was I was able to download pretrained models as of 8 days ago. Not sure what’s changed since then…</p>

Jiafeng: <p>I met the same error. Simple reinstall and upgrade tqdm solved!<br>
pip uninstall tqdm<br>
pip install tqdm</p>
<p>If still not work, use pip install tqdm==4.46(any version rather than the previous one)</p>

_MGabriel: <p>I had the same issue and this is the only thing that works for me</p>
<pre><code class="lang-auto">pip uninstall tqdm
pip install tqdm
</code></pre>