Same code one is ok, but another can't run

username: 111186
cooked: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/1/e10780ef00549455af9f095a534037bf074a2490.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/e10780ef00549455af9f095a534037bf074a2490" title="11"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/e/1/e10780ef00549455af9f095a534037bf074a2490_2_690x335.jpeg" alt="11" data-base62-sha1="w6HvsdoVgQ8CKE79OGDkgz2DS4U" width="690" height="335" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/e/1/e10780ef00549455af9f095a534037bf074a2490_2_690x335.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/e/1/e10780ef00549455af9f095a534037bf074a2490_2_1035x502.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/e/1/e10780ef00549455af9f095a534037bf074a2490_2_1380x670.jpeg 2x" data-dominant-color="30302B"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">11</span><span class="informations">3011×1463 308 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div> <div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/a/9/a9e322bc1b7c5df377054514f63c3f3cc6d8f12d.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/a9e322bc1b7c5df377054514f63c3f3cc6d8f12d" title="12"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/a/9/a9e322bc1b7c5df377054514f63c3f3cc6d8f12d_2_689x276.jpeg" alt="12" data-base62-sha1="oeTkmBFOdoialkOZRaGpPiLDwF7" width="689" height="276" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/a/9/a9e322bc1b7c5df377054514f63c3f3cc6d8f12d_2_689x276.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/a/9/a9e322bc1b7c5df377054514f63c3f3cc6d8f12d_2_1033x414.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/a/9/a9e322bc1b7c5df377054514f63c3f3cc6d8f12d_2_1378x552.jpeg 2x" data-dominant-color="2F3638"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">12</span><span class="informations">2581×1035 124 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
I want use the the pre-train-model, but it’s always wrong so i make a test in the picture , one is run in my own computer(it is ok, pytorch version is 1.3.0) another is run in the DGX-station(it was wrong,pytorch version is 1.0.1). help me</p>

username: torslim
cooked: <p>Could this have something to do with the fact that in the second example you are using the pretrained model, which possibly changes the dimensions of the input the model expects? What happens if you try using <code>pretrained=True</code> in the first example as well (or remove <code>pretrained=True</code> in the second example)?</p>

username: ptrblck
cooked: <p>Are you using the same <code>torchvision</code> versions for both runs?<br>
Note that adaptive pooling layers were not always in the model definition, which would explain the size mismatch for an older <code>torchvision</code>.</p>

username: 111186
cooked: <p>thank you for your answer, it try ,but it doesn’t work i think it may be the version of pytoch</p>

username: 111186
cooked: <p><code>torchvision</code>  versions is the pytorch’ version? if it is the problem how can i solve the problem about the adaptive pooling layers</p>

username: ptrblck
cooked: <p>No, <code>torchvision</code> is built on top of PyTorch.<br>
If you update PyTorch with torchvision to the latest stable version, both codes should work.</p>

username: 111186
cooked: <p>thanks , i check my torchvision, one is 0.2.1(it can’t run), another is 0.4.1 (it is ok). can you explain more details about the adaptive pooling layers , i want know why it doesn’t work in the old version</p>

username: ptrblck
cooked: <p>In previous versions <code>nn.MaxPool2d</code> was used before the flattening of the activation (as seen <a href="https://github.com/pytorch/vision/blob/1d0a3b11c6406e8b604c2c95b228bc6f7bc36ac4/torchvision/models/vgg.py#L43">here</a>), which restricts the input shapes to the original shape, which is <code>[batch_size, 3, 224, 224]</code>.<br>
Adaptive pooling layers output an activation with a specified size, so that you can now use inputs with a smaller or bigger spatial size, and the adaptive pooling layer will make sure, the output activation before the flattening has the desired shape.</p>
<p>This is necessary as linear layers have a fixed number in input features, which your flattened activation has to match.</p>

username: 111186
cooked: <p>thanks, due to i use the DGX station and the CUDA version is  9.0.176(i can’t update the version, because others are use the station), so i searched the version that pytorch-version can match.<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/c/5/c5e7ee025f6d2528aace9e14b40aed2c3f3fcab0.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/c5e7ee025f6d2528aace9e14b40aed2c3f3fcab0" title="123"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/c/5/c5e7ee025f6d2528aace9e14b40aed2c3f3fcab0_2_690x51.jpeg" alt="123" data-base62-sha1="seKY48SKYhE7iAfjjByWvjBXsPe" width="690" height="51" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/c/5/c5e7ee025f6d2528aace9e14b40aed2c3f3fcab0_2_690x51.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/c/5/c5e7ee025f6d2528aace9e14b40aed2c3f3fcab0_2_1035x76.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/c/5/c5e7ee025f6d2528aace9e14b40aed2c3f3fcab0_2_1380x102.jpeg 2x" data-dominant-color="EAEBEF"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">123</span><span class="informations">1467×109 14.2 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div> does the pytorch-version(1.1.0) and the trochvision(0.3.0) . are the two versions is ok for adaptive pooling layers?</p>

username: ptrblck
cooked: <p><code>torchvision==0.3.0</code> will have the adaptive pooling layers.<br>
The binaries ship with their own CUDA, cudnn, etc. libraries, so you don’t need a matching local CUDA installation.</p>

username: imaluengo
cooked: <p>You could always upgrade DGX to Ubuntu 18.04 that comes with CUDA 10:<br>
<a href="https://docs.nvidia.com/dgx/dgx-station-user-guide/index.html#upgrading-dgx-os-software-release" class="onebox" target="_blank" rel="nofollow noopener">https://docs.nvidia.com/dgx/dgx-station-user-guide/index.html#upgrading-dgx-os-software-release</a></p>

username: alanzhai219
cooked: <p>I have reproduced this error. The magic happens in torchvision instead of pytorch version. ‘class VGG’ in //vision/torchvision/models/vgg.py has changed! The simple way is to update torchvision as <a class="mention" href="/u/ptrblck">@ptrblck</a> metioned. Of course, you can update old vgg.py according to new version torchvision.</p>
<pre><code class="lang-python">import torch
def __init__
    ...
    self.avgpool = nn.AdaptiveAvgPool2d((7,7))
    ...
def forward
    ...
    # x = x.view(x.size(0), -1)
    x = self.avgpool(x)
    x = torch.flatten(x, 1)
    ...
</code></pre>
<p>Both pytorch1.0 and 1.3 work well on my changes.<br>
BTW, 尽量不要在目录中用中文，以避免不期望的行为</p>