|
9 | 9 | buildMetadataFileName, documentationPageUrls, llamaCppDirectory, llamaDirectory, llamaLocalBuildBinsDirectory, |
10 | 10 | llamaPrebuiltBinsDirectory, llamaToolchainsDirectory |
11 | 11 | } from "../../config.js"; |
12 | | -import {BuildMetadataFile, BuildOptions, convertBuildOptionsToBuildOptionsJSON} from "../types.js"; |
| 12 | +import {BuildGpu, BuildMetadataFile, BuildOptions, convertBuildOptionsToBuildOptionsJSON} from "../types.js"; |
13 | 13 | import {spawnCommand, SpawnError} from "../../utils/spawnCommand.js"; |
14 | 14 | import {downloadCmakeIfNeeded, fixXpackPermissions, getCmakePath, hasBuiltinCmake} from "../../utils/cmake.js"; |
15 | 15 | import {getConsoleLogPrefix} from "../../utils/getConsoleLogPrefix.js"; |
@@ -54,7 +54,7 @@ export async function compileLlamaCpp(buildOptions: BuildOptions, compileOptions |
54 | 54 |
|
55 | 55 | const outDirectory = path.join(llamaLocalBuildBinsDirectory, finalBuildFolderName); |
56 | 56 |
|
57 | | - let parallelBuildThreads = getParallelBuildThreadsToUse(platform); |
| 57 | + let parallelBuildThreads = getParallelBuildThreadsToUse(platform, buildOptions.gpu, ciMode); |
58 | 58 | if (ignoreWorkarounds.includes("singleBuildThread")) |
59 | 59 | parallelBuildThreads = 1; |
60 | 60 | else if (ignoreWorkarounds.includes("reduceParallelBuildThreads")) |
@@ -502,9 +502,12 @@ async function getToolchainFileForArch(targetArch: string) { |
502 | 502 | return null; |
503 | 503 | } |
504 | 504 |
|
505 | | -function getParallelBuildThreadsToUse(platform: BinaryPlatform) { |
| 505 | +function getParallelBuildThreadsToUse(platform: BinaryPlatform, gpu?: BuildGpu, ciMode: boolean = false) { |
506 | 506 | const cpuCount = os.cpus().length; |
507 | 507 |
|
| 508 | + if (ciMode && platform === "win" && gpu === "cuda" && cpuCount === 4) |
| 509 | + return 3; // workaround for `compiler is out of heap space` error on GitHub Actions on Windows when building with CUDA |
| 510 | + |
508 | 511 | if (cpuCount <= 4) |
509 | 512 | return cpuCount; |
510 | 513 |
|
|
0 commit comments