containers / ramalama

The goal of RamaLama is to make working with AI boring.
MIT License
193 stars 27 forks source link

resumable downloads via ollama #258

Open ericcurtin opened 14 hours ago

ericcurtin commented 14 hours ago

When downloading huge models > 10 GB , it's not uncommon for the download to fail before it's fully downloaded.

In our client when this happens one must download the whole model from the start which is frustrating.

In Ollama client, the download can be resumed, rather than being fully downloaded again.

This can make some larger models on Ollama registry almost impossible to download via ramalama client.

ericcurtin commented 14 hours ago

@swarajpande5 is this something you could take a look at?

ericcurtin commented 14 hours ago

This is an example of what a failure looks like:

$ ramalama pull ollama://granite-code:20b
Pulling granite-code/20b: 100% ▕####################▏ 0.98k/0.98k 2.02MB/s
Pulling 2d2d4235410b43ab: 100% ▕####################▏ 568/568 1.10MB/s 00:0
Pulling 1ab42a69b797a9bb:  10% ▕#9                  ▏ 1.07G/10.8G 3.30MB/s
Traceback (most recent call last):
  File "/Users/ecurtin/git/ramalama/bin/ramalama", line 88, in <module>
    main(sys.argv[1:])
  File "/Users/ecurtin/git/ramalama/bin/ramalama", line 66, in main
    args.func(args)
  File "/Users/ecurtin/git/ramalama/ramalama/cli.py", line 321, in pull_cli
    return model.pull(args)
           ^^^^^^^^^^^^^^^^
  File "/Users/ecurtin/git/ramalama/ramalama/ollama.py", line 111, in pull
    return init_pull(
           ^^^^^^^^^^
  File "/Users/ecurtin/git/ramalama/ramalama/ollama.py", line 77, in init_pull
    pull_blob(repos, layer_digest, accept, registry_head, models, model_name, model_tag, symlink_path)
  File "/Users/ecurtin/git/ramalama/ramalama/ollama.py", line 54, in pull_blob
    download_file(url, layer_blob_path, headers=headers)
  File "/Users/ecurtin/git/ramalama/ramalama/ollama.py", line 27, in download_file
    chunk = response.read(chunk_size)
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 479, in read
    s = self.fp.read(amt)
        ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/socket.py", line 720, in readinto
    return self._sock.recv_into(b)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ssl.py", line 1251, in recv_into
    return self.read(nbytes, buffer)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ssl.py", line 1103, in read
    return self._sslobj.read(len, buffer)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ssl.SSLError: [SSL] record layer failure (_ssl.c:2559)