25
25
session = tf .InteractiveSession ()
26
26
27
27
28
- def dump_info ():
29
- numpy_path = os .path .dirname (numpy .__file__ )
30
- print ("Numpy path: %r" % numpy_path )
31
- so_files = Util .sysexecOut ("find %s | grep \" \.so\" " % numpy_path , shell = True )
32
- print ("Numpy so files:\n ---\n %s\n ---\n " % so_files )
33
- so_files = [f for f in so_files .splitlines () if f ]
28
+ def sys_exec (* args , shell = False ):
29
+ print ("$ %s" % " " .join (args ))
30
+ out = Util .sysexecOut (* args , shell = shell )
31
+ print (out )
32
+
33
+
34
+ def debug_lib_so (f , syms = ()):
34
35
ldd = "ldd"
35
36
if sys .platform == "darwin" :
36
37
ldd = "otool -L"
37
38
objdump = "objdump -T"
38
39
if sys .platform == "darwin" :
39
40
objdump = "otool -IHGv"
41
+ cmd = "%s %s" % (ldd , f )
42
+ sys_exec (cmd , shell = True )
43
+ for sym in syms :
44
+ cmd = "%s %s | { grep %s || true; }" % (objdump , f , sym )
45
+ sys_exec (cmd , shell = True )
46
+
47
+
48
+ def dump_info ():
49
+ # Some generic stuff.
50
+ sys_exec ("g++" , "--version" )
51
+ print ("TF include:" , tf .sysconfig .get_include ())
52
+ print ("TF lib:" , tf .sysconfig .get_lib ())
53
+ tf_lib_so = tf .sysconfig .get_lib () + "/libtensorflow_framework.so"
54
+ tf_pywrap_so = tf .sysconfig .get_lib () + "/python/_pywrap_tensorflow_internal.so"
55
+ sys_exec ("ls" , "-la" , tf .sysconfig .get_lib ())
56
+ if os .path .exists (tf_lib_so ):
57
+ print ("TF lib so exists:" , tf_lib_so )
58
+ debug_lib_so (tf_lib_so , ["_ZTIN10tensorflow8OpKernelE" ])
59
+ else :
60
+ print ("TF lib so does not(!) exist:" , tf_lib_so )
61
+ if os .path .exists (tf_pywrap_so ):
62
+ print ("TF pywrap so exists:" , tf_pywrap_so )
63
+ debug_lib_so (tf_pywrap_so , ["_ZTIN10tensorflow8OpKernelE" ])
64
+ else :
65
+ print ("TF pywrap so does not(!) exist:" , tf_pywrap_so )
66
+ # See OpCodeCompiler. Is already not used anymore but still maybe relevant.
67
+ if hasattr (sys , "getdlopenflags" ) and hasattr (sys , "setdlopenflags" ):
68
+ print ("have (set|get)dlopenflags" )
69
+ import ctypes
70
+ print ("Cur flags: %r, RTLD_GLOBAL is set: %r" % (sys .getdlopenflags (), sys .getdlopenflags () & ctypes .RTLD_GLOBAL ))
71
+ if os .path .exists ("/proc" ):
72
+ print ("Have /proc" )
73
+ sys_exec ("cat" , "/proc/%i/maps" % os .getpid ())
74
+ # Numpy stuff, debugging if sgemm was not found:
75
+ numpy_path = os .path .dirname (numpy .__file__ )
76
+ print ("Numpy path: %r" % numpy_path )
77
+ so_files = Util .sysexecOut ("find %s | grep \" \.so\" " % numpy_path , shell = True )
78
+ print ("Numpy so files:\n ---\n %s\n ---\n " % so_files )
79
+ so_files = [f for f in so_files .splitlines () if f ]
40
80
for f in so_files :
41
- cmd = "%s %s" % (ldd , f )
42
- print ("$ %s" % cmd )
43
- out = Util .sysexecOut (cmd , shell = True )
44
- print (out )
45
- cmd = "%s %s | { grep sgemm || true; }" % (objdump , f )
46
- print ("$ %s" % cmd )
47
- out = Util .sysexecOut (cmd , shell = True )
48
- print (out )
81
+ debug_lib_so (f , ["sgemm" ])
49
82
50
83
51
84
def test_dummy ():
@@ -55,7 +88,7 @@ def test_dummy():
55
88
56
89
def test_make_lstm_op_auto_cuda ():
57
90
try :
58
- make_lstm_op ()
91
+ make_lstm_op (compiler_opts = { "verbose" : True } )
59
92
except tf .errors .NotFoundError :
60
93
dump_info ()
61
94
raise
@@ -64,7 +97,7 @@ def test_make_lstm_op_auto_cuda():
64
97
def test_make_lstm_op_no_cuda ():
65
98
try :
66
99
OpMaker .with_cuda = False
67
- make_lstm_op ()
100
+ make_lstm_op (compiler_opts = { "verbose" : True } )
68
101
except tf .errors .NotFoundError :
69
102
dump_info ()
70
103
raise
@@ -930,8 +963,12 @@ def test_fast_bw_uniform():
930
963
if k .startswith ("test_" ):
931
964
print ("-" * 40 )
932
965
print ("Executing: %s" % k )
933
- v ()
966
+ try :
967
+ v ()
968
+ except unittest .SkipTest as exc :
969
+ print ("SkipTest: %s" % exc )
934
970
print ("-" * 40 )
971
+ print ("All passed." )
935
972
else :
936
973
assert len (sys .argv ) >= 2
937
974
for arg in sys .argv [1 :]:
0 commit comments