Skip to content

Conversation

@amirzia
Copy link
Contributor

@amirzia amirzia commented May 17, 2024

Ref: #7252

@ngxson
Copy link
Collaborator

ngxson commented May 17, 2024

Also, wouldn't it be nice to have LLAMA_CACHE default to $HOME/.cache/llama.cpp?

~/.cache actually exist on all modern desktop linux distro: https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html

On windows, the equivalent of .cache is std::getenv("APPDATA")

Not sure what it is on macos.

@mofosyne mofosyne added enhancement New feature or request Review Complexity : Low Trivial changes to code that most beginner devs (or those who want a break) can tackle. e.g. UI fix labels May 18, 2024
@amirzia amirzia marked this pull request as draft May 18, 2024 07:12
@amirzia
Copy link
Contributor Author

amirzia commented May 18, 2024

@ngxson Thanks for the comments. The default cache locations for all the 3 OSes are updated. The default application cache directory for macOS is ~/Library/Caches (+).

If the implementation looks good, I can go ahead and update the documentation accordingly.

@amirzia amirzia requested review from ggerganov and ngxson May 18, 2024 10:48
@amirzia amirzia marked this pull request as ready for review May 18, 2024 10:48
cache_directory = std::getenv("HOME") + std::string("/.cache/");
}
#elif defined(__APPLE__)
cache_directory = std::getenv("HOME") + std::string("/Library/Caches/");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think on Mac os pretty much all apps also use ~/.cache (so, same as linux)

Just my 2 cents

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't use macos very often so I'm not sure. Maybe @ggerganov knows more about this?

My assumption is that ~/.cache widely used by applications ported from linux (maybe?), while ~/Library/Caches is the conventional OS X way (according to this documentation).

In either way, having model cached under user's $HOME is already very nice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see apps caches in both places on my machine - I guess either way is fine. Don't have an opinion

Copy link
Collaborator

@ngxson ngxson May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep ~/Library/Caches then (as it is referred in apple's documentation)

@amirzia amirzia requested review from julien-c and ngxson May 20, 2024 15:21
cache_directory += "llama.cpp";
cache_directory += DIRECTORY_SEPARATOR;
}
const bool success = create_directory_with_parents(cache_directory);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you forgot to remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, it should be removed now :)

Copy link
Member

@ggerganov ggerganov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amirzia amirzia requested a review from ngxson May 21, 2024 12:28
}
params.model = cache_directory + string_split(params.hf_file, '/').back();
}
} else if (!params.model_url.empty()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question: Do you think we should also use cache dir under this condition params.model_url? @ggerganov

For now only params.hf_repo enables cache dir.

Copy link
Collaborator

@ngxson ngxson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'd prefer to also support cache dir with --model-url. But that's not very important for now.

@ggerganov ggerganov merged commit 11474e7 into ggml-org:master May 21, 2024
#elif defined(__APPLE__)
cache_directory = std::getenv("HOME") + std::string("/Library/Caches/");
#elif defined(_WIN32)
cache_directory = std::getenv("APPDATA");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, the cache directory on Windows is %LOCALAPPDATA% (see platformdirs). %APPDATA% will be synced synced between computers in an Active Directory domain ("Roaming").

Nexesenex pushed a commit to Nexesenex/croco.cpp that referenced this pull request May 21, 2024
* examples: cache hf model when --model not provided

* examples: cache hf model when --model not provided

* examples: cache hf model when --model not provided

* examples: cache hf model when --model not provided

* examples: cache hf model when --model not provided
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request examples Review Complexity : Low Trivial changes to code that most beginner devs (or those who want a break) can tackle. e.g. UI fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants