SSL errors when trying to Generate_CoreML_Model
When running this:
./models/generate-coreml-model.sh base.en
I get this:
def backtrace(trace: np.ndarray):
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1037, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 975, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1454, in connect
self.sock = self._context.wrap_socket(self.sock,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 512, in wrap_socket
return self.sslsocket_class._create(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1070, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1341, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/dac/Documents/Whisper/whisper.cpp/models/convert-whisper-to-coreml.py", line 308, in <module>
whisper = load_model(args.model).cpu()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/whisper/__init__.py", line 131, in load_model
checkpoint_file = _download(_MODELS[name], download_root, in_memory)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/whisper/__init__.py", line 67, in _download
with urllib.request.urlopen(url) as source, open(download_target, "wb") as output:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 216, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 519, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 496, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1391, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>
xcrun: error: unable to find utility "coremlc", not a developer tool or in PATH
mv: rename models/coreml-encoder-base.en.mlmodelc to models/ggml-base.en-encoder.mlmodelc: No such file or directory ```
https://github.com/ggerganov/whisper.cpp/issues/898
Anyone figure this out? I'm getting the exact same error and #898 didn't help. But it's weird because it worked a week ago and I'm using the same computer.
Anyone figure this out? I'm getting the exact same error and #898 didn't help. But it's weird because it worked a week ago and I'm using the same computer.
For anyone else having this issue. Mine was fixed by using miniconda as I had multiple conflicting versions of python installed on my machine when this requires python 3.10 to work well. (Also I uninstalled the second python version from my mac but it worked before I did so)
It looks like the server hosting the target model is giving an invalid HTTPS certificate (probably too new for the default Python CA on my system, macOS 14.7.1 + python 3.11.9). Here's what I did (very hacky):
-
open
venv/lib/python3.11/site-packages/whisper/__init__.py -
patch the
urlopencall to usecertificerts:import certifi print(f"[TRACE] opening {url}") with urllib.request.urlopen(url, cafile=certifi.where()) as source, open(download_target, "wb") as output: ...
For reference, the URL I was using: https://openaipublic.azureedge.net/main/whisper/models/aff26ae408abcba5fbf8813c21e62b0941638c5f6eebfb145be0c9839262a19a/large-v3-turbo.pt.
This URL works fine with a call to cURL, so the certs seem valid, just not working with urllib.
@brokegen thanks for the info, i did similar and it worked.
# file: /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py
import certifi
def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
*, cafile=certifi.where(), capath=None, cadefault=False, context=None):
'''Open the URL url, which can be either a string or a Request object.
+1