提交 8ebe5708 authored 作者: Frederic's avatar Frederic

When calling subprocess.Popen on windows, don't open command line windows.

上级 6ef19365
...@@ -6,6 +6,7 @@ from theano.configparser import ( ...@@ -6,6 +6,7 @@ from theano.configparser import (
AddConfigVar, BoolParam, ConfigParam, EnumStr, IntParam, AddConfigVar, BoolParam, ConfigParam, EnumStr, IntParam,
TheanoConfigParser) TheanoConfigParser)
from theano.misc.cpucount import cpuCount from theano.misc.cpucount import cpuCount
from theano.misc.windows import call_subprocess_Popen
_logger = logging.getLogger('theano.configdefaults') _logger = logging.getLogger('theano.configdefaults')
...@@ -99,8 +100,9 @@ enum = EnumStr("g++", "") ...@@ -99,8 +100,9 @@ enum = EnumStr("g++", "")
# in an unusual Python 2.4.4 Windows environment with the default stdin=None. # in an unusual Python 2.4.4 Windows environment with the default stdin=None.
dummy_stdin = open(os.devnull) dummy_stdin = open(os.devnull)
try: try:
subprocess.Popen('g++', stdout=subprocess.PIPE, stderr=subprocess.PIPE, call_subprocess_Popen('g++', stdout=subprocess.PIPE,
stdin=dummy_stdin.fileno()) stderr=subprocess.PIPE,
stdin=dummy_stdin.fileno())
# Keep the default linker the same as the one for the mode FAST_RUN # Keep the default linker the same as the one for the mode FAST_RUN
AddConfigVar('linker', AddConfigVar('linker',
("Default linker used if the theano flags mode is Mode " ("Default linker used if the theano flags mode is Mode "
......
...@@ -22,6 +22,7 @@ import theano ...@@ -22,6 +22,7 @@ import theano
from theano.gof.utils import flatten from theano.gof.utils import flatten
from theano.configparser import config from theano.configparser import config
from theano.gof.cc import hash_from_code from theano.gof.cc import hash_from_code
from theano.misc.windows import call_subprocess_Popen
# we will abuse the lockfile mechanism when reading and writing the registry # we will abuse the lockfile mechanism when reading and writing the registry
import compilelock import compilelock
...@@ -1592,7 +1593,7 @@ class GCC_compiler(object): ...@@ -1592,7 +1593,7 @@ class GCC_compiler(object):
print >> sys.stderr, ' '.join(cmd) print >> sys.stderr, ' '.join(cmd)
try: try:
p = subprocess.Popen(cmd, stderr=subprocess.PIPE) p = call_subprocess_Popen(cmd, stderr=subprocess.PIPE)
compile_stderr = p.communicate()[1] compile_stderr = p.communicate()[1]
except Exception: except Exception:
# An exception can occur e.g. if `g++` is not found. # An exception can occur e.g. if `g++` is not found.
......
...@@ -3,8 +3,8 @@ import errno ...@@ -3,8 +3,8 @@ import errno
import os import os
import platform import platform
import re import re
import subprocess
import shutil import shutil
import subprocess
import sys import sys
import textwrap import textwrap
...@@ -13,6 +13,7 @@ import numpy ...@@ -13,6 +13,7 @@ import numpy
import theano import theano
from theano.configparser import config, AddConfigVar, ConfigParam, StrParam from theano.configparser import config, AddConfigVar, ConfigParam, StrParam
from theano.gof.utils import flatten from theano.gof.utils import flatten
from theano.misc.windows import call_subprocess_Popen
# Using the dummy file descriptors below is a workaround for a crash # Using the dummy file descriptors below is a workaround for a crash
# experienced in an unusual Python 2.4.4 Windows environment with the default # experienced in an unusual Python 2.4.4 Windows environment with the default
...@@ -21,8 +22,10 @@ dummy_in = open(os.devnull) ...@@ -21,8 +22,10 @@ dummy_in = open(os.devnull)
dummy_err = open(os.devnull, 'w') dummy_err = open(os.devnull, 'w')
p = None p = None
try: try:
p = subprocess.Popen(['g++', '-dumpversion'], stdout=subprocess.PIPE, p = call_subprocess_Popen(['g++', '-dumpversion'],
stdin=dummy_in.fileno(), stderr=dummy_err.fileno()) stdout=subprocess.PIPE,
stdin=dummy_in.fileno(),
stderr=dummy_err.fileno())
p.wait() p.wait()
gcc_version_str = p.stdout.readline().strip() gcc_version_str = p.stdout.readline().strip()
except OSError: except OSError:
......
...@@ -20,6 +20,7 @@ import warnings ...@@ -20,6 +20,7 @@ import warnings
import theano import theano
from theano import config from theano import config
from theano.misc.windows import call_subprocess_Popen
import cc import cc
import graph import graph
...@@ -788,10 +789,10 @@ class OpenMPOp(Op): ...@@ -788,10 +789,10 @@ class OpenMPOp(Op):
os.write(fd, code) os.write(fd, code)
os.close(fd) os.close(fd)
fd = None fd = None
proc = subprocess.Popen(['g++', '-fopenmp', path], proc = call_subprocess_Popen(['g++', '-fopenmp', path],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
stdin=dummy_stdin.fileno()) stdin=dummy_stdin.fileno())
proc.wait() proc.wait()
if proc.returncode != 0: if proc.returncode != 0:
default_openmp = False default_openmp = False
......
...@@ -15,6 +15,7 @@ from theano.gof.cmodule import (std_libs, std_lib_dirs, ...@@ -15,6 +15,7 @@ from theano.gof.cmodule import (std_libs, std_lib_dirs,
std_include_dirs, dlimport, std_include_dirs, dlimport,
get_lib_extension, local_bitwidth) get_lib_extension, local_bitwidth)
from theano.gof.python25 import any from theano.gof.python25 import any
from theano.misc.windows import call_subprocess_Popen
_logger = logging.getLogger("theano.sandbox.cuda.nvcc_compiler") _logger = logging.getLogger("theano.sandbox.cuda.nvcc_compiler")
_logger.setLevel(logging.WARN) _logger.setLevel(logging.WARN)
...@@ -64,8 +65,9 @@ nvcc_version = None ...@@ -64,8 +65,9 @@ nvcc_version = None
def is_nvcc_available(): def is_nvcc_available():
"""Return True iff the nvcc compiler is found.""" """Return True iff the nvcc compiler is found."""
def set_version(): def set_version():
p = subprocess.Popen([nvcc_path, '--version'], stdout=subprocess.PIPE, p = call_subprocess_Popen([nvcc_path, '--version'],
stderr=subprocess.PIPE) stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
p.wait() p.wait()
s = p.stdout.readlines()[-1].split(',')[1].strip().split() s = p.stdout.readlines()[-1].split(',')[1].strip().split()
assert s[0] == 'release' assert s[0] == 'release'
......
...@@ -60,6 +60,7 @@ import subprocess ...@@ -60,6 +60,7 @@ import subprocess
import sys import sys
import datetime import datetime
import theano import theano
from theano.misc.windows import call_subprocess_Popen
def main(stdout=None, stderr=None, argv=None, theano_nose=None, def main(stdout=None, stderr=None, argv=None, theano_nose=None,
...@@ -264,7 +265,7 @@ def run(stdout, stderr, argv, theano_nose, batch_size, time_profile, ...@@ -264,7 +265,7 @@ def run(stdout, stderr, argv, theano_nose, batch_size, time_profile,
data["ids"][test_id])) data["ids"][test_id]))
f_rawlog.flush() f_rawlog.flush()
proc = subprocess.Popen( proc = call_subprocess_Popen(
([python, theano_nose, '-v', '--with-id'] ([python, theano_nose, '-v', '--with-id']
+ [str(test_id)] + argv + + [str(test_id)] + argv +
['--disabdocstring']), ['--disabdocstring']),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论