Skip to content

Commit 152e8ca

Browse files
committed
feat: add --gpus option
1 parent 14df5b2 commit 152e8ca

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/argv.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,10 @@ export class Argv {
388388
return this.map.get("containerEmulate") ?? null;
389389
}
390390

391+
get gpus (): string | null {
392+
return this.map.get("gpus") ?? null;
393+
}
394+
391395
get concurrency (): number | null {
392396
const concurrency = this.map.get("concurrency");
393397
if (!concurrency) return null;

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,11 @@ process.on("SIGUSR2", async () => {
366366
description: "The name, without the architecture, of a gitlab hosted runner to emulate. See here: https://docs.gitlab.com/ee/ci/runners/hosted_runners/linux.html#machine-types-available-for-linux---x86-64",
367367
choices: GitlabRunnerPresetValues,
368368
})
369+
.option("gpus", {
370+
type: "string",
371+
description: "A list of GPU indexes or 'all'",
372+
requiresArg: true,
373+
})
369374
.option("color", {
370375
requiresArg: false,
371376
default: true,

src/job.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,10 @@ If you know what you're doing and would like to suppress this warning, use one o
986986
dockerCmd += `--cpus=${cpuConfig} `;
987987
}
988988

989+
if (this.argv.gpus) {
990+
dockerCmd += `--gpus ${this.argv.gpus} --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 `;
991+
}
992+
989993
// host and none networks have to be specified using --network, since they cannot be used with
990994
// `docker network connect`.
991995
for (const network of this.argv.network) {
@@ -1579,6 +1583,10 @@ If you know what you're doing and would like to suppress this warning, use one o
15791583
dockerCmd += `--shm-size=${this.argv.shmSize} `;
15801584
}
15811585

1586+
if (this.argv.gpus) {
1587+
dockerCmd += `--gpus ${this.argv.gpus} --ipc=host --ulimit memlock=-1 --ulimit stack=67108864`;
1588+
}
1589+
15821590
for (const volume of this.argv.volume) {
15831591
dockerCmd += `--volume ${volume} `;
15841592
}

0 commit comments

Comments
 (0)