Pytorch model takes forever to load

Yanhong_Zhao: <p>I am running simple loading of pre-trained model from my jupyter notebook and it takes forever to do it.<br>
Code:<br>
from torchvision import models<br>
model_ft = models.inception_v3(pretrained=use_pretrained)</p>
<p>the model parameters are downloaded before and it worked fine and I have restarted my computer and it is still not working. When I interrupt the kernel, this is the output:</p>
<hr>
<p>KeyboardInterrupt                         Traceback (most recent call last)<br>
 in <br>
----&gt; 1 model_ft = models.inception_v3(pretrained=use_pretrained)</p>
<p>~/anaconda/envs/cs231n/lib/python3.7/site-packages/torchvision/models/inception.py in inception_v3(pretrained, progress, **kwargs)<br>
51         else:<br>
52             original_aux_logits = True<br>
—&gt; 53         model = Inception3(**kwargs)<br>
54         state_dict = load_state_dict_from_url(model_urls[‘inception_v3_google’],<br>
55                                               progress=progress)</p>
<p>~/anaconda/envs/cs231n/lib/python3.7/site-packages/torchvision/models/inception.py in <strong>init</strong>(self, num_classes, aux_logits, transform_input, inception_blocks)<br>
109                 stddev = m.stddev if hasattr(m, ‘stddev’) else 0.1<br>
110                 X = stats.truncnorm(-2, 2, scale=stddev)<br>
–&gt; 111                 values = torch.as_tensor(X.rvs(m.weight.numel()), dtype=m.weight.dtype)<br>
112                 values = values.view(m.weight.size())<br>
113                 with torch.no_grad():</p>
<p>~/anaconda/envs/cs231n/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py in rvs(self, size, random_state)<br>
461         kwds = self.kwds.copy()<br>
462         kwds.update({‘size’: size, ‘random_state’: random_state})<br>
–&gt; 463         return self.dist.rvs(*self.args, **kwds)<br>
464<br>
465     def sf(self, x):</p>
<p>~/anaconda/envs/cs231n/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py in rvs(self, *args, **kwds)<br>
978         # by _rvs().<br>
979         self._size = size<br>
–&gt; 980         vals = self._rvs(*args)<br>
981<br>
982         vals = vals * scale + loc</p>
<p>~/anaconda/envs/cs231n/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py in _rvs(self, *args)<br>
911         ## Use basic inverse cdf algorithm for RV generation as default.<br>
912         U = self._random_state.random_sample(self._size)<br>
–&gt; 913         Y = self._ppf(U, *args)<br>
914         return Y<br>
915</p>
<p>~/anaconda/envs/cs231n/lib/python3.7/site-packages/scipy/stats/_continuous_distns.py in _ppf(self, q, a, b)<br>
7161<br>
7162     def _ppf(self, q, a, b):<br>
-&gt; 7163         return _truncnorm_ppf(q, a, b)<br>
7164<br>
7165     def _munp(self, n, a, b):</p>
<p>~/anaconda/envs/cs231n/lib/python3.7/site-packages/scipy/stats/_continuous_distns.py in vf_wrapper(*args)<br>
6931         <span class="mention">@functools.wraps</span>(f)<br>
6932         def vf_wrapper(*args):<br>
-&gt; 6933             return vf(*args)<br>
6934         return vf_wrapper<br>
6935     return vectorize_decorator</p>
<p>~/anaconda/envs/cs231n/lib/python3.7/site-packages/numpy/lib/function_base.py in <strong>call</strong>(self, *args, **kwargs)<br>
2089             vargs.extend([kwargs[_n] for _n in names])<br>
2090<br>
-&gt; 2091         return self._vectorize_call(func=func, args=vargs)<br>
2092<br>
2093     def _get_ufunc_and_otypes(self, func, args):</p>
<p>~/anaconda/envs/cs231n/lib/python3.7/site-packages/numpy/lib/function_base.py in _vectorize_call(self, func, args)<br>
2165                       for a in args]<br>
2166<br>
-&gt; 2167             outputs = ufunc(*inputs)<br>
2168<br>
2169             if ufunc.nout == 1:</p>
<p>~/anaconda/envs/cs231n/lib/python3.7/site-packages/scipy/stats/_continuous_distns.py in _truncnorm_ppf(q, a, b)<br>
7079     if q &gt;= 1:<br>
7080         return b<br>
-&gt; 7081     delta = _truncnorm_get_delta(a, b)<br>
7082     if delta &gt; 0:<br>
7083         if a &gt; 0:</p>
<p>~/anaconda/envs/cs231n/lib/python3.7/site-packages/scipy/stats/_continuous_distns.py in _truncnorm_get_delta(a, b)<br>
6942         delta = _norm_cdf(b) - _norm_cdf(a)<br>
6943     else:<br>
-&gt; 6944         delta = _norm_sf(a) - _norm_sf(b)<br>
6945     delta = max(delta, 0)<br>
6946     return delta</p>
<p>~/anaconda/envs/cs231n/lib/python3.7/site-packages/scipy/stats/_continuous_distns.py in _norm_sf(x)<br>
198<br>
199 def _norm_sf(x):<br>
–&gt; 200     return _norm_cdf(-x)<br>
201<br>
202</p>
<p>~/anaconda/envs/cs231n/lib/python3.7/site-packages/scipy/stats/_continuous_distns.py in _norm_cdf(x)<br>
186<br>
187 def _norm_cdf(x):<br>
–&gt; 188     return sc.ndtr(x)<br>
189<br>
190</p>
<p>KeyboardInterrupt:</p>
<p>However loading model from torch hub works just fine:<br>
model_ft = torch.hub.load(‘pytorch/vision’, ‘inception_v3’, pretrained=True)</p>

ptrblck: <p>Seems to be related to <a href="https://discuss.pytorch.org/t/torchvisions-inception-v3-takes-much-longer-to-load-than-other-models/68756/9">this issue</a>.</p>