Skip to content

Commit baaca82

Browse files
committed
feat: add --gpus automatically if tag specified
1 parent 152e8ca commit baaca82

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

src/job.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -986,8 +986,8 @@ 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 `;
989+
if (this.gpus) {
990+
dockerCmd += `--gpus ${this.gpus} --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 `;
991991
}
992992

993993
// host and none networks have to be specified using --network, since they cannot be used with
@@ -1223,6 +1223,19 @@ If you know what you're doing and would like to suppress this warning, use one o
12231223
return image.entrypoint;
12241224
}
12251225

1226+
get gpus (): string | null {
1227+
if (this.argv.gpus) {
1228+
return this.argv.gpus;
1229+
} else if ("tags" in this.jobData) {
1230+
for (const tag of this.jobData["tags"]) {
1231+
if (tag.match(/^(.*-)?gpu(-.*)?$/)) {
1232+
return "all";
1233+
}
1234+
}
1235+
}
1236+
return null;
1237+
}
1238+
12261239
private async validateCiDependencyProxyServerAuthentication (imageName: string) {
12271240
const CI_DEPENDENCY_PROXY_SERVER = this._variables["CI_DEPENDENCY_PROXY_SERVER"];
12281241
if (!imageName.startsWith(CI_DEPENDENCY_PROXY_SERVER)) {
@@ -1583,8 +1596,8 @@ If you know what you're doing and would like to suppress this warning, use one o
15831596
dockerCmd += `--shm-size=${this.argv.shmSize} `;
15841597
}
15851598

1586-
if (this.argv.gpus) {
1587-
dockerCmd += `--gpus ${this.argv.gpus} --ipc=host --ulimit memlock=-1 --ulimit stack=67108864`;
1599+
if (this.gpus) {
1600+
dockerCmd += `--gpus ${this.gpus} --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 `;
15881601
}
15891602

15901603
for (const volume of this.argv.volume) {

0 commit comments

Comments
 (0)