Unverified Commit d047d6f4 authored by J-shang's avatar J-shang Committed by GitHub
Browse files

fix reuse local and trial (#3408)

parent 79d3c492
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import ctypes import ctypes
import os import os
import sys
import shlex import shlex
import tarfile import tarfile
import time import time
...@@ -88,9 +89,12 @@ class Trial: ...@@ -88,9 +89,12 @@ class Trial:
trial_command = self.args.trial_command trial_command = self.args.trial_command
gpuIndices = self.data.get('gpuIndices') gpuIndices = self.data.get("gpuIndices")
if (gpuIndices is not None): if (gpuIndices is not None):
trial_command = 'CUDA_VISIBLE_DEVICES="%s " %s' % (gpuIndices, trial_command) if sys.platform == "win32":
trial_command = 'set CUDA_VISIBLE_DEVICES="%s " && call %s' % (gpuIndices, trial_command)
else:
trial_command = 'CUDA_VISIBLE_DEVICES="%s " %s' % (gpuIndices, trial_command)
self.log_pipe_stdout = self.trial_syslogger_stdout.get_pipelog_reader() self.log_pipe_stdout = self.trial_syslogger_stdout.get_pipelog_reader()
self.process = Popen(trial_command, shell=True, stdout=self.log_pipe_stdout, self.process = Popen(trial_command, shell=True, stdout=self.log_pipe_stdout,
......
...@@ -92,9 +92,11 @@ export class LocalEnvironmentService extends EnvironmentService { ...@@ -92,9 +92,11 @@ export class LocalEnvironmentService extends EnvironmentService {
private getScript(environment: EnvironmentInformation): string[] { private getScript(environment: EnvironmentInformation): string[] {
const script: string[] = []; const script: string[] = [];
if (process.platform === 'win32') { if (process.platform === 'win32') {
script.push(`$env:PATH="${process.env.path}"`)
script.push(`cd $env:${this.experimentRootDir}`); script.push(`cd $env:${this.experimentRootDir}`);
script.push(`New-Item -ItemType "directory" -Path ${path.join(this.experimentRootDir, 'envs', environment.id)} -Force`); script.push(`New-Item -ItemType "directory" -Path ${path.join(this.experimentRootDir, 'envs', environment.id)} -Force`);
environment.command = `cd envs\\${environment.id} && python -m nni.tools.trial_tool.trial_runner`; script.push(`cd envs\\${environment.id}`);
environment.command = `python -m nni.tools.trial_tool.trial_runner`;
script.push( script.push(
`cmd.exe /c ${environment.command} --job_pid_file ${path.join(environment.runnerWorkingFolder, 'pid')} 2>&1 | Out-File "${path.join(environment.runnerWorkingFolder, 'trial_runner.log')}" -encoding utf8`, `cmd.exe /c ${environment.command} --job_pid_file ${path.join(environment.runnerWorkingFolder, 'pid')} 2>&1 | Out-File "${path.join(environment.runnerWorkingFolder, 'trial_runner.log')}" -encoding utf8`,
`$NOW_DATE = [int64](([datetime]::UtcNow)-(get-date "1/1/1970")).TotalSeconds`, `$NOW_DATE = [int64](([datetime]::UtcNow)-(get-date "1/1/1970")).TotalSeconds`,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment