Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/argv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ export class Argv {
return this.map.get("containerEmulate") ?? null;
}

get gpus (): string | null {
return this.map.get("gpus") ?? null;
}

get concurrency (): number | null {
const concurrency = this.map.get("concurrency");
if (!concurrency) return null;
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ process.on("SIGUSR2", async () => {
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",
choices: GitlabRunnerPresetValues,
})
.option("gpus", {
type: "string",
description: "A list of GPU indexes or 'all'",
requiresArg: true,
})
.option("color", {
requiresArg: false,
default: true,
Expand Down
21 changes: 21 additions & 0 deletions src/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,10 @@ If you know what you're doing and would like to suppress this warning, use one o
dockerCmd += `--cpus=${cpuConfig} `;
}

if (this.gpus) {
dockerCmd += `--gpus ${this.gpus} --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 `;
}

// host and none networks have to be specified using --network, since they cannot be used with
// `docker network connect`.
for (const network of this.argv.network) {
Expand Down Expand Up @@ -1219,6 +1223,19 @@ If you know what you're doing and would like to suppress this warning, use one o
return image.entrypoint;
}

get gpus (): string | null {
if (this.argv.gpus) {
return this.argv.gpus;
} else if ("tags" in this.jobData) {
for (const tag of this.jobData["tags"]) {
if (tag.match(/^(.*-)?gpu(-.*)?$/)) {
return "all";
}
}
}
return null;
}

private async validateCiDependencyProxyServerAuthentication (imageName: string) {
const CI_DEPENDENCY_PROXY_SERVER = this._variables["CI_DEPENDENCY_PROXY_SERVER"];
if (!imageName.startsWith(CI_DEPENDENCY_PROXY_SERVER)) {
Expand Down Expand Up @@ -1579,6 +1596,10 @@ If you know what you're doing and would like to suppress this warning, use one o
dockerCmd += `--shm-size=${this.argv.shmSize} `;
}

if (this.gpus) {
dockerCmd += `--gpus ${this.gpus} --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 `;
}

for (const volume of this.argv.volume) {
dockerCmd += `--volume ${volume} `;
}
Expand Down