Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

add gpuNum check for local TS #378

Merged
merged 3 commits into from
Nov 22, 2018
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class LocalTrainingServiceForGPU extends LocalTrainingService {
this.requiredGPUNum = 0;
}
this.log.info('required GPU number is ' + this.requiredGPUNum);
if (this.gpuScheduler === undefined) {
if (this.gpuScheduler === undefined && this.requiredGPUNum > 0) {
this.gpuScheduler = new GPUScheduler();
}
break;
Expand All @@ -78,7 +78,7 @@ class LocalTrainingServiceForGPU extends LocalTrainingService {
}

protected onTrialJobStatusChanged(trialJob: LocalTrialJobDetailForGPU, oldStatus: TrialJobStatus): void {
if (trialJob.gpuIndices !== undefined && trialJob.gpuIndices.length !== 0) {
if (trialJob.gpuIndices !== undefined && trialJob.gpuIndices.length !== 0 && this.gpuScheduler !== undefined) {
if (oldStatus === 'RUNNING' && trialJob.status !== 'RUNNING') {
for (const index of trialJob.gpuIndices) {
this.availableGPUIndices[index] = false;
Expand All @@ -93,7 +93,7 @@ class LocalTrainingServiceForGPU extends LocalTrainingService {
const variables: { key: string; value: string }[] = super.getEnvironmentVariables(trialJobDetail, resource);
variables.push({
key: 'CUDA_VISIBLE_DEVICES',
value: resource.gpuIndices.join(',')
value: this.gpuScheduler === undefined ? '' : resource.gpuIndices.join(',')
});

return variables;
Expand Down Expand Up @@ -125,8 +125,10 @@ class LocalTrainingServiceForGPU extends LocalTrainingService {

protected occupyResource(resource: { gpuIndices: number[] }): void {
super.occupyResource(resource);
for (const index of resource.gpuIndices) {
this.availableGPUIndices[index] = true;
if (this.gpuScheduler !== undefined) {
for (const index of resource.gpuIndices) {
this.availableGPUIndices[index] = true;
}
}
}
}
Expand Down