Connection interrupted error when downloading LucaOne checkpoints in fetch_checkpoints.py
Description
When running the fetch_checkpoints.py script to download the pre-trained model checkpoints of LucaOne, a connection interruption issue was encountered. The specific error message is as follows:
(lucavirus_tasks) [user@ubuntu src]$ python fetch_checkpoints.py
------Download Trained LLM(LucaOne)------
********************Downloading********************
Downloading LucaOne TrainedCheckPoint: LucaOne-v2.0-20231125113045-17600000 ...
Wait a moment(8G), please.
Downloading logs.txt...
('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
Download automatically LucaOne Trained CheckPoint failed!
You can manually download 'logs/' and 'models/' into local directory: /data/LucaVirusTasks/llm/ from http://47.93.21.181/lucaone/TrainedCheckPoint
Traceback (most recent call last):
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/site-packages/urllib3/connectionpool.py", line 670, in urlopen
httplib_response = self._make_request(
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/site-packages/urllib3/connectionpool.py", line 426, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/site-packages/urllib3/connectionpool.py", line 421, in _make_request
httplib_response = conn.getresponse()
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/http/client.py", line 1377, in getresponse
response.begin()
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/http/client.py", line 320, in begin
version, status, reason = self._read_status()
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/http/client.py", line 289, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/site-packages/urllib3/connectionpool.py", line 726, in urlopen
retries = retries.increment(
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/site-packages/urllib3/util/retry.py", line 410, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/site-packages/urllib3/packages/six.py", line 734, in reraise
raise value.with_traceback(tb)
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/site-packages/urllib3/connectionpool.py", line 670, in urlopen
httplib_response = self._make_request(
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/site-packages/urllib3/connectionpool.py", line 426, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/site-packages/urllib3/connectionpool.py", line 421, in _make_request
httplib_response = conn.getresponse()
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/http/client.py", line 1377, in getresponse
response.begin()
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/http/client.py", line 320, in begin
version, status, reason = self._read_status()
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/http/client.py", line 289, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/LucaVirusTasks/src/utils.py", line 999, in download_trained_checkpoint_lucaone
download_folder(logs_base_url, logs_file_names, logs_local_dir)
File "/data/LucaVirusTasks/src/utils.py", line 938, in download_folder
download_file(file_url, local_filename)
File "/data/LucaVirusTasks/src/utils.py", line 918, in download_file
with requests.get(url, stream=True) as r:
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/site-packages/requests/api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/home/user/miniconda3/envs/lucavirus_tasks/lib/python3.9/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/LucaVirusTasks/src/fetch_checkpoints.py", line 135, in <module>
main()
File "/data/LucaVirusTasks/src/fetch_checkpoints.py", line 52, in main
download_trained_checkpoint_lucaone(
File "/data/LucaVirusTasks/src/utils.py", line 1014, in download_trained_checkpoint_lucaone
raise Exception(e)
Exception: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
Expected Result
The script should successfully download the pre-trained model checkpoints of LucaOne.
Actual Result
A connection interruption error occurred during the download process, causing the automatic download to fail.
The issue has been resolved. You can replace the download_file function in utils.py with the code below to use the system's wget tool, which supports resumable downloads and retries. Please follow these steps:
Open the project file at src/utils.py.
Locate the original definition of def download_file(...) and completely replace it with the implementation provided below.
Ensure that wget is installed on your system (most Linux distributions include it by default).
Save the file and rerun python fetch_checkpoints.py. The script will now use wget for downloading, which is more robust for large files.
import os
import subprocess
# Replace the original download_file function with this implementation using wget
# to achieve reliable, resumable downloads for large files.
def download_file(url: str, local_path: str):
"""
Download a file from a URL to a local path using the system's wget tool.
Supports resuming partial downloads, configurable retries, and timeout.
Parameters:
url (str): The remote URL of the file to download.
local_path (str): The local filesystem path where the file will be saved.
"""
# Ensure the target directory exists
os.makedirs(os.path.dirname(local_path), exist_ok=True)
# Construct the wget command:
# -c enables resume support
# --tries specifies the maximum number of retries
# --timeout sets the network timeout in seconds
cmd = [
"wget",
"-c", # resume downloads
"--tries=5", # retry up to 5 times on failure
"--timeout=30", # timeout after 30 seconds of inactivity
url,
"-O", # output file path
local_path
]
print(f"Downloading {url} to {local_path} using wget...")
try:
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
raise RuntimeError(f"Failed to download {url} with wget: {e}")
Thank you very much for sharing the solution! We do notice that some user may encounter network issue while downloading. We recommend that users who encounter issues with automatic model downloads manually download the pre-trained weights from http://47.93.21.181/lucavirus/TrainedCheckPoint and place the logs and models folders in the <project_root>/llm directory.