When training the model, load some pre training models, such as VGg. The code is as follows
model = torchvision.models.vgg19(pretrained=True)
Train will display
Downloading: "https://download.pytorch.org/models/vgg19-dcbb9e9d.pth" to /root/.cache/torch/checkpoints/vgg19-dcbb9e9d.pth
Then an error occurred:
socket.gaierror: [Errno -3] Temporary failure in name resolution
and
urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution>
This is because the pre training model cannot be downloaded, so it needs to be downloaded from the Internet
therefore, it is more convenient to download the model first, find a way to connect to the Internet, and then input the link automatically https://download.pytorch.org/models/vgg19-dcbb9e9d.pth
Then put the downloaded. PTH model file under a fixed path, such as
/home/team/torch/models/pre_ model/vgg19-dcbb9e9d.pth
Finally, change the code to
model = torchvision.models.vgg19(pretrained=False)
pthfile = r'/home/team/torch/models/pre_model/vgg19-dcbb9e9d.pth'
model.load_state_dict(torch.load(pthfile))```
Read More:
- [Solved] Pytorch Download CIFAR1 Datas Error: urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certi
- [Solved] urllib.error.URLError: <urlopen error [SSL: WRONG_VERSION_NUMBER] wrong version number
- [Solved] urllib.error.URLError: urlopen error [SSL: CERTIFICATE_VERIFY_FAILED]
- Error when downloading the built-in dataset of pytoch = urllib.error.urlerror: urlopen error [SSL: certificate_verify_failed]
- [Solved] raise ContentTooShortError(urllib.error.ContentTooShortError: <urlopen error retrieval incomplete:
- python chatterbot [nltk_data] Error loading stopwords: <urlopen error [Errno 11004]
- SSL error of urllib3 when Python uploads files using Minio
- Python 3 urllib has no URLEncode attribute
- [Solved]AttributeError: module ‘urllib’ has no attribute ‘quote’
- urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=‘localhost‘, port=8097): Max retries excee
- Using Python error urlopen error unknown URL type: the solution of HTTPS
- urllib.error.HTTPError: HTTP Error 403: Forbidden [How to Solve]
- Python error: urllib.error.HTTPError : http Error 404: not found
- [Solved] with ERRTYPE = cudaError CUDA failure 999 unknown error
- urllib.error.HTTPError http error 403 forbidden
- Python openpyxl excel open zipfile error resolution: zipfile.BadZipFile: File is not a zip file
- Pytorch Loading model error: RuntimeError: Error(s) in loading state_dict for Model: Missing key(s) in state_dict
- [Solved] Pytorch Error: RuntimeError: Error(s) in loading state_dict for Network: size mismatch