-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URLError: certificate verify failed: certificate has expired #195
Labels
bug
Something isn't working
Comments
This looks like an expired SSL certificate in the pretrainedmodels package. This will need to be fixed on their end. In the meantime, some people suggest disabling SSL verification as a temporary workaround:
To disable SSL verification, add the following to the top of your Python script:
|
jamesdolezal
changed the title
[BUG] Placeholder title
[BUG] URLError: certificate verify failed: certificate has expired
Nov 5, 2022
jamesdolezal
changed the title
[BUG] URLError: certificate verify failed: certificate has expired
URLError: certificate verify failed: certificate has expired
Nov 5, 2022
Hi, Im trying to download these files but i cannot, please help. Thanks.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I get this result with the line commad: results = trainer.train(train_dts, val_dts)
Do you have please any idea how I could resolve this issue?
Thank you in advance for your help.
Best
[18:12:22] INFO Steps per epoch = 5128
Downloading: "http://data.lip6.fr/cadene/pretrainedmodels/xception-43020ad28.pth" to /home/nazim/.cache/torch/hub/checkpoints/xception-43020ad28.pth
SSLCertVerificationError Traceback (most recent call last)
File ~/anaconda3/envs/slideflow/lib/python3.10/urllib/request.py:1348, in AbstractHTTPHandler.do_open(self, http_class, req, **http_conn_args)
1347 try:
-> 1348 h.request(req.get_method(), req.selector, req.data, headers,
1349 encode_chunked=req.has_header('Transfer-encoding'))
1350 except OSError as err: # timeout error
File ~/anaconda3/envs/slideflow/lib/python3.10/http/client.py:1282, in HTTPConnection.request(self, method, url, body, headers, encode_chunked)
1281 """Send a complete request to the server."""
-> 1282 self._send_request(method, url, body, headers, encode_chunked)
File ~/anaconda3/envs/slideflow/lib/python3.10/http/client.py:1328, in HTTPConnection._send_request(self, method, url, body, headers, encode_chunked)
1327 body = _encode(body, 'body')
-> 1328 self.endheaders(body, encode_chunked=encode_chunked)
File ~/anaconda3/envs/slideflow/lib/python3.10/http/client.py:1277, in HTTPConnection.endheaders(self, message_body, encode_chunked)
1276 raise CannotSendHeader()
-> 1277 self._send_output(message_body, encode_chunked=encode_chunked)
File ~/anaconda3/envs/slideflow/lib/python3.10/http/client.py:1037, in HTTPConnection._send_output(self, message_body, encode_chunked)
1036 del self._buffer[:]
-> 1037 self.send(msg)
1039 if message_body is not None:
1040
1041 # create a consistent interface to message_body
File ~/anaconda3/envs/slideflow/lib/python3.10/http/client.py:975, in HTTPConnection.send(self, data)
974 if self.auto_open:
--> 975 self.connect()
976 else:
File ~/anaconda3/envs/slideflow/lib/python3.10/http/client.py:1454, in HTTPSConnection.connect(self)
1452 server_hostname = self.host
-> 1454 self.sock = self._context.wrap_socket(self.sock,
1455 server_hostname=server_hostname)
File ~/anaconda3/envs/slideflow/lib/python3.10/ssl.py:513, in SSLContext.wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
507 def wrap_socket(self, sock, server_side=False,
508 do_handshake_on_connect=True,
509 suppress_ragged_eofs=True,
510 server_hostname=None, session=None):
511 # SSLSocket class handles server_hostname encoding before it calls
512 # ctx._wrap_socket()
--> 513 return self.sslsocket_class._create(
514 sock=sock,
515 server_side=server_side,
516 do_handshake_on_connect=do_handshake_on_connect,
517 suppress_ragged_eofs=suppress_ragged_eofs,
518 server_hostname=server_hostname,
519 context=self,
520 session=session
521 )
File ~/anaconda3/envs/slideflow/lib/python3.10/ssl.py:1071, in SSLSocket._create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
1070 raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
-> 1071 self.do_handshake()
1072 except (OSError, ValueError):
File ~/anaconda3/envs/slideflow/lib/python3.10/ssl.py:1342, in SSLSocket.do_handshake(self, block)
1341 self.settimeout(None)
-> 1342 self._sslobj.do_handshake()
1343 finally:
SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997)
During handling of the above exception, another exception occurred:
URLError Traceback (most recent call last)
Input In [28], in <cell line: 1>()
----> 1 results = trainer.train(train_dts, val_dts)
File ~/slideflow/slideflow/model/torch.py:1674, in Trainer.train(self, train_dts, val_dts, log_frequency, validate_on_batch, validation_batch_size, validation_steps, starting_epoch, ema_observations, ema_smoothing, use_tensorboard, steps_per_epoch_override, save_predictions, save_model, resume_training, pretrain, checkpoint, multi_gpu, norm_fit, reduce_method, seed, from_wsi, roi_method)
1671 self._prepare_neptune_run(train_dts, 'train')
1673 # Build model
-> 1674 self._build_model(checkpoint, pretrain)
1675 assert self.model is not None
1677 # Print model summary
File ~/slideflow/slideflow/model/torch.py:565, in Trainer._build_model(self, checkpoint, pretrain)
563 self.load(checkpoint)
564 else:
--> 565 self.model = self.hp.build_model(
566 labels=self.labels,
567 pretrain=pretrain,
568 num_slide_features=self.num_slide_features
569 )
570 # Create an inference model before any multi-GPU parallelization
571 # is applied to the self.model parameter
572 self.inference_model = self.model
File ~/slideflow/slideflow/model/torch.py:312, in ModelParams.build_model(self, labels, num_classes, num_slide_features, pretrain, checkpoint)
310 # Build base model
311 if self.model in ('xception', 'nasnet_large'):
--> 312 _model = self.ModelDict[self.model](
313 num_classes=1000,
314 pretrained=pretrain
315 )
316 else:
317 # Compatibility logic for prior versions of PyTorch
318 model_fn = self.ModelDict[self.model]
File ~/anaconda3/envs/slideflow/lib/python3.10/site-packages/pretrainedmodels/models/xception.py:223, in xception(num_classes, pretrained)
219 assert num_classes == settings['num_classes'],
220 "num_classes should be {}, but is {}".format(settings['num_classes'], num_classes)
222 model = Xception(num_classes=num_classes)
--> 223 model.load_state_dict(model_zoo.load_url(settings['url']))
225 model.input_space = settings['input_space']
226 model.input_size = settings['input_size']
File ~/anaconda3/envs/slideflow/lib/python3.10/site-packages/torch/hub.py:727, in load_state_dict_from_url(url, model_dir, map_location, progress, check_hash, file_name)
725 r = HASH_REGEX.search(filename) # r is Optional[Match[str]]
726 hash_prefix = r.group(1) if r else None
--> 727 download_url_to_file(url, cached_file, hash_prefix, progress=progress)
729 if _is_legacy_zip_format(cached_file):
730 return _legacy_zip_load(cached_file, model_dir, map_location)
File ~/anaconda3/envs/slideflow/lib/python3.10/site-packages/torch/hub.py:593, in download_url_to_file(url, dst, hash_prefix, progress)
591 file_size = None
592 req = Request(url, headers={"User-Agent": "torch.hub"})
--> 593 u = urlopen(req)
594 meta = u.info()
595 if hasattr(meta, 'getheaders'):
File ~/anaconda3/envs/slideflow/lib/python3.10/urllib/request.py:216, in urlopen(url, data, timeout, cafile, capath, cadefault, context)
214 else:
215 opener = _opener
--> 216 return opener.open(url, data, timeout)
File ~/anaconda3/envs/slideflow/lib/python3.10/urllib/request.py:525, in OpenerDirector.open(self, fullurl, data, timeout)
523 for processor in self.process_response.get(protocol, []):
524 meth = getattr(processor, meth_name)
--> 525 response = meth(req, response)
527 return response
File ~/anaconda3/envs/slideflow/lib/python3.10/urllib/request.py:634, in HTTPErrorProcessor.http_response(self, request, response)
631 # According to RFC 2616, "2xx" code indicates that the client's
632 # request was successfully received, understood, and accepted.
633 if not (200 <= code < 300):
--> 634 response = self.parent.error(
635 'http', request, response, code, msg, hdrs)
637 return response
File ~/anaconda3/envs/slideflow/lib/python3.10/urllib/request.py:557, in OpenerDirector.error(self, proto, *args)
555 http_err = 0
556 args = (dict, proto, meth_name) + args
--> 557 result = self._call_chain(*args)
558 if result:
559 return result
File ~/anaconda3/envs/slideflow/lib/python3.10/urllib/request.py:496, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
494 for handler in handlers:
495 func = getattr(handler, meth_name)
--> 496 result = func(*args)
497 if result is not None:
498 return result
File ~/anaconda3/envs/slideflow/lib/python3.10/urllib/request.py:749, in HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers)
746 fp.read()
747 fp.close()
--> 749 return self.parent.open(new, timeout=req.timeout)
File ~/anaconda3/envs/slideflow/lib/python3.10/urllib/request.py:519, in OpenerDirector.open(self, fullurl, data, timeout)
516 req = meth(req)
518 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method())
--> 519 response = self._open(req, data)
521 # post-process response
522 meth_name = protocol+"_response"
File ~/anaconda3/envs/slideflow/lib/python3.10/urllib/request.py:536, in OpenerDirector._open(self, req, data)
533 return result
535 protocol = req.type
--> 536 result = self._call_chain(self.handle_open, protocol, protocol +
537 '_open', req)
538 if result:
539 return result
File ~/anaconda3/envs/slideflow/lib/python3.10/urllib/request.py:496, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
494 for handler in handlers:
495 func = getattr(handler, meth_name)
--> 496 result = func(*args)
497 if result is not None:
498 return result
File ~/anaconda3/envs/slideflow/lib/python3.10/urllib/request.py:1391, in HTTPSHandler.https_open(self, req)
1390 def https_open(self, req):
-> 1391 return self.do_open(http.client.HTTPSConnection, req,
1392 context=self._context, check_hostname=self._check_hostname)
File ~/anaconda3/envs/slideflow/lib/python3.10/urllib/request.py:1351, in AbstractHTTPHandler.do_open(self, http_class, req, **http_conn_args)
1348 h.request(req.get_method(), req.selector, req.data, headers,
1349 encode_chunked=req.has_header('Transfer-encoding'))
1350 except OSError as err: # timeout error
-> 1351 raise URLError(err)
1352 r = h.getresponse()
1353 except:
URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997)>
The text was updated successfully, but these errors were encountered: