You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import os
from huggingface_hub import HfApi, ModelCard, logging
from . import __version__
card = ModelCard.load(hf_path)
card.data.tags = ["mlx"] if card.data.tags is None else card.data.tags + ["mlx"]
card.text = dedent(
f"""
# {upload_repo}
This model was converted to MLX format from [`{hf_path}`]() using mlx-lm version **{__version__}**.
Refer to the [original model card](https://huggingface.co/{hf_path}) for more details on the model.
## Use with mlx
```bash
pip install mlx-lm
```
```python
from mlx_lm import load, generate
model, tokenizer = load("{upload_repo}")
response = generate(model, tokenizer, prompt="hello", verbose=True)
```
"""
)
card.save(os.path.join(path, "README.md"))
logging.set_verbosity_info()
api = HfApi()
api.create_repo(repo_id=upload_repo, exist_ok=True)
api.upload_folder(
folder_path=path,
repo_id=upload_repo,
repo_type="model",
)
print(f"Upload successful, go to https://huggingface.co/{upload_repo} for details.")
Logs
model.safetensors: 100%|█████| 1.15G/1.15G [04:19<00:00, 4.43MB/s]
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/urllib3/connectionpool.py", line 793, in urlopen
response = self._make_request(
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/urllib3/connectionpool.py", line 537, in _make_request
response = conn.getresponse()
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/urllib3/connection.py", line 466, in getresponse
httplib_response = super().getresponse()
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/http/client.py", line 1348, in getresponse
response.begin()
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/http/client.py", line 316, in begin
version, status, reason = self._read_status()
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/http/client.py", line 277, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/ssl.py", line 1274, in recv_into
return self.read(nbytes, buffer)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/ssl.py", line 1132, inreadreturn self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 54] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/requests/adapters.py", line 486, in send
resp = conn.urlopen(
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/urllib3/connectionpool.py", line 847, in urlopen
retries = retries.increment(
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/urllib3/util/retry.py", line 470, in increment
raise reraise(type(error), error, _stacktrace)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/urllib3/util/util.py", line 38, in reraise
raise value.with_traceback(tb)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/urllib3/connectionpool.py", line 793, in urlopen
response = self._make_request(
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/urllib3/connectionpool.py", line 537, in _make_request
response = conn.getresponse()
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/urllib3/connection.py", line 466, in getresponse
httplib_response = super().getresponse()
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/http/client.py", line 1348, in getresponse
response.begin()
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/http/client.py", line 316, in begin
version, status, reason = self._read_status()
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/http/client.py", line 277, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/ssl.py", line 1274, in recv_into
return self.read(nbytes, buffer)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/ssl.py", line 1132, inreadreturn self._sslobj.read(len, buffer)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/huggingface_hub/_commit_api.py", line 402, in _wrapped_lfs_upload
lfs_upload(operation=operation, lfs_batch_action=batch_action, headers=headers, endpoint=endpoint)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/huggingface_hub/lfs.py", line 243, in lfs_upload
_upload_multi_part(operation=operation, header=header, chunk_size=chunk_size, upload_url=upload_url)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/huggingface_hub/lfs.py", line 345, in _upload_multi_part
completion_res = get_session().post(
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/requests/sessions.py", line 637, in post
return self.request("POST", url, data=data, json=json, **kwargs)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/huggingface_hub/utils/_http.py", line 68, in send
returnsuper().send(request, *args, **kwargs)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/requests/adapters.py", line 501, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: (ProtocolError('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer')), '(Request ID: 39049708-259a-4d58-82c9-e71a959d2f15)')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/mlx_lm/convert.py", line 58, in<module>
convert(**vars(args))
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/mlx_lm/utils.py", line 624, in convert
upload_to_hub(mlx_path, upload_repo, hf_path)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/mlx_lm/utils.py", line 468, in upload_to_hub
api.upload_folder(
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 119, in _inner_fn
return fn(*args, **kwargs)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 1230, in _inner
return fn(self, *args, **kwargs)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 4807, in upload_folder
commit_info = self.create_commit(
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 119, in _inner_fn
return fn(*args, **kwargs)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 1230, in _inner
return fn(self, *args, **kwargs)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 3770, in create_commit
self.preupload_lfs_files(
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 4271, in preupload_lfs_files
_upload_lfs_files(
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 119, in _inner_fn
return fn(*args, **kwargs)
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/huggingface_hub/_commit_api.py", line 412, in _upload_lfs_files
_wrapped_lfs_upload(filtered_actions[0])
File "/opt/homebrew/Caskroom/miniconda/base/envs/mlx_code/lib/python3.8/site-packages/huggingface_hub/_commit_api.py", line 404, in _wrapped_lfs_upload
raise RuntimeError(f"Error while uploading '{operation.path_in_repo}' to the Hub.") from exc
RuntimeError: Error while uploading 'model.safetensors' to the Hub
Hi @Blaizzy I'm sorry about the inconvenience. This might be a transient error and it's hard per-se to know what happened here. Have you retried to upload the file? In some cases, it can come from a temporary network outage (wifi disconnects) but hard to tell
No, I tried again with 10 models it didn't work. Then I updated my python from 3.8 to 3.10 and reinstalled every library but I still get the same error.
Describe the bug
When I try to upload models to the hub it fails.
Reproduction
Logs
System info
The text was updated successfully, but these errors were encountered: