Advertisement
kopyl

Untitled

Sep 22nd, 2024
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.46 KB | None | 0 0
  1. import multiprocessing
  2. from huggingface_hub import hf_hub_download
  3.  
  4. def download_file(model_name, filename):
  5.     try:
  6.         model_path = hf_hub_download(model_name, filename=filename)
  7.         print(f"Successfully downloaded: {filename}")
  8.         return model_path
  9.     except Exception as e:
  10.         print(f"Error downloading {filename}: {str(e)}")
  11.         return None
  12.  
  13. def download_files_parallel(model_name, file_parts):
  14.     with multiprocessing.Pool() as pool:
  15.         results = pool.starmap(
  16.             download_file,
  17.             [(model_name, filename) for filename in file_parts]
  18.         )
  19.     return results
  20.  
  21. if __name__ == "__main__":
  22.     model_name = "mradermacher/Tess-3-Llama-3.1-405B-GGUF"
  23.     file_parts = [
  24.         "Tess-3-Llama-3.1-405B.Q8_0.gguf.part1of9",
  25.         "Tess-3-Llama-3.1-405B.Q8_0.gguf.part2of9",
  26.         "Tess-3-Llama-3.1-405B.Q8_0.gguf.part3of9",
  27.         "Tess-3-Llama-3.1-405B.Q8_0.gguf.part4of9",
  28.         "Tess-3-Llama-3.1-405B.Q8_0.gguf.part5of9",
  29.         "Tess-3-Llama-3.1-405B.Q8_0.gguf.part6of9",
  30.         "Tess-3-Llama-3.1-405B.Q8_0.gguf.part7of9",
  31.         "Tess-3-Llama-3.1-405B.Q8_0.gguf.part8of9",
  32.         "Tess-3-Llama-3.1-405B.Q8_0.gguf.part9of9",
  33.     ]
  34.    
  35.     downloaded_paths = download_files_parallel(model_name, file_parts)
  36.    
  37.     for filename, path in zip(file_parts, downloaded_paths):
  38.         if path:
  39.             print(f"{filename}: {path}")
  40.         else:
  41.             print(f"{filename}: Download failed")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement