|
56 | 56 | #pragma warning(disable: 4244 4267) // possible loss of data |
57 | 57 | #endif |
58 | 58 |
|
59 | | -#if (defined(GGML_USE_CUDA) || defined(GGML_USE_SYCL)) |
60 | | -#define GGML_USE_CUDA_SYCL |
61 | | -#endif |
62 | | - |
63 | | -#if (defined(GGML_USE_CUDA) || defined(GGML_USE_SYCL)) || defined(GGML_USE_VULKAN) |
64 | | -#define GGML_USE_CUDA_SYCL_VULKAN |
65 | | -#endif |
66 | | - |
67 | 59 | #if defined(LLAMA_USE_CURL) |
68 | 60 | #ifdef __linux__ |
69 | 61 | #include <linux/limits.h> |
@@ -949,11 +941,37 @@ struct ggml_threadpool_params ggml_threadpool_params_from_cpu_params(const cpu_p |
949 | 941 |
|
950 | 942 | #ifdef LLAMA_USE_CURL |
951 | 943 |
|
| 944 | +#define CURL_MAX_RETRY 3 |
| 945 | +#define CURL_RETRY_DELAY_SECONDS 2 |
| 946 | + |
| 947 | + |
952 | 948 | static bool starts_with(const std::string & str, const std::string & prefix) { |
953 | 949 | // While we wait for C++20's std::string::starts_with... |
954 | 950 | return str.rfind(prefix, 0) == 0; |
955 | 951 | } |
956 | 952 |
|
| 953 | +static bool curl_perform_with_retry(const std::string& url, CURL* curl, int max_attempts, int retry_delay_seconds) { |
| 954 | + int remaining_attempts = max_attempts; |
| 955 | + |
| 956 | + while (remaining_attempts > 0) { |
| 957 | + fprintf(stderr, "%s: Trying to download from %s (attempt %d of %d)...\n", __func__ , url.c_str(), max_attempts - remaining_attempts + 1, max_attempts); |
| 958 | + |
| 959 | + CURLcode res = curl_easy_perform(curl); |
| 960 | + if (res == CURLE_OK) { |
| 961 | + return true; |
| 962 | + } |
| 963 | + |
| 964 | + int exponential_backoff_delay = std::pow(retry_delay_seconds, max_attempts - remaining_attempts) * 1000; |
| 965 | + fprintf(stderr, "%s: curl_easy_perform() failed: %s, retrying after %d milliseconds...\n", __func__, curl_easy_strerror(res), exponential_backoff_delay); |
| 966 | + |
| 967 | + remaining_attempts--; |
| 968 | + std::this_thread::sleep_for(std::chrono::milliseconds(exponential_backoff_delay)); |
| 969 | + } |
| 970 | + |
| 971 | + fprintf(stderr, "%s: curl_easy_perform() failed after %d attempts\n", __func__, max_attempts); |
| 972 | + return false; |
| 973 | +} |
| 974 | + |
957 | 975 | static bool llama_download_file(const std::string & url, const std::string & path, const std::string & hf_token) { |
958 | 976 |
|
959 | 977 | // Initialize libcurl |
@@ -1057,9 +1075,8 @@ static bool llama_download_file(const std::string & url, const std::string & pat |
1057 | 1075 | curl_easy_setopt(curl.get(), CURLOPT_HEADERFUNCTION, static_cast<CURLOPT_HEADERFUNCTION_PTR>(header_callback)); |
1058 | 1076 | curl_easy_setopt(curl.get(), CURLOPT_HEADERDATA, &headers); |
1059 | 1077 |
|
1060 | | - CURLcode res = curl_easy_perform(curl.get()); |
1061 | | - if (res != CURLE_OK) { |
1062 | | - fprintf(stderr, "%s: curl_easy_perform() failed: %s\n", __func__, curl_easy_strerror(res)); |
| 1078 | + bool was_perform_successful = curl_perform_with_retry(url, curl.get(), CURL_MAX_RETRY, CURL_RETRY_DELAY_SECONDS); |
| 1079 | + if (!was_perform_successful) { |
1063 | 1080 | return false; |
1064 | 1081 | } |
1065 | 1082 |
|
@@ -1134,11 +1151,10 @@ static bool llama_download_file(const std::string & url, const std::string & pat |
1134 | 1151 | }; |
1135 | 1152 |
|
1136 | 1153 | // start the download |
1137 | | - fprintf(stderr, "%s: downloading from %s to %s (server_etag:%s, server_last_modified:%s)...\n", __func__, |
1138 | | - llama_download_hide_password_in_url(url).c_str(), path.c_str(), headers.etag.c_str(), headers.last_modified.c_str()); |
1139 | | - auto res = curl_easy_perform(curl.get()); |
1140 | | - if (res != CURLE_OK) { |
1141 | | - fprintf(stderr, "%s: curl_easy_perform() failed: %s\n", __func__, curl_easy_strerror(res)); |
| 1154 | + fprintf(stderr, "%s: trying to download model from %s to %s (server_etag:%s, server_last_modified:%s)...\n", __func__, |
| 1155 | + llama_download_hide_password_in_url(url).c_str(), path.c_str(), headers.etag.c_str(), headers.last_modified.c_str()); |
| 1156 | + bool was_perform_successful = curl_perform_with_retry(url, curl.get(), CURL_MAX_RETRY, CURL_RETRY_DELAY_SECONDS); |
| 1157 | + if (!was_perform_successful) { |
1142 | 1158 | return false; |
1143 | 1159 | } |
1144 | 1160 |
|
@@ -1812,6 +1828,7 @@ void yaml_dump_non_result_info(FILE * stream, const gpt_params & params, const l |
1812 | 1828 | fprintf(stream, "cpu_has_sve: %s\n", ggml_cpu_has_sve() ? "true" : "false"); |
1813 | 1829 | fprintf(stream, "cpu_has_f16c: %s\n", ggml_cpu_has_f16c() ? "true" : "false"); |
1814 | 1830 | fprintf(stream, "cpu_has_fp16_va: %s\n", ggml_cpu_has_fp16_va() ? "true" : "false"); |
| 1831 | + fprintf(stream, "cpu_has_riscv_v: %s\n", ggml_cpu_has_riscv_v() ? "true" : "false"); |
1815 | 1832 | fprintf(stream, "cpu_has_wasm_simd: %s\n", ggml_cpu_has_wasm_simd() ? "true" : "false"); |
1816 | 1833 | fprintf(stream, "cpu_has_blas: %s\n", ggml_cpu_has_blas() ? "true" : "false"); |
1817 | 1834 | fprintf(stream, "cpu_has_sse3: %s\n", ggml_cpu_has_sse3() ? "true" : "false"); |
|
0 commit comments