Discussion:
[theano-users] Numpy error during optimization phase
n***@gmail.com
2018-01-24 10:05:50 UTC
Permalink
Hi everyone,

While using an OpFromGraph involving some operations with binary values,
there is an optimization error:

theano.gof.opt: ERROR: Optimization failure due to: local_add_canonizer
Elemwise{add,no_inplace}(InplaceDimShuffle{0,1,x}.0,
InplaceDimShuffle{x,0,1}.0)
File "/home/granger/dev/Theano/theano/gof/opt.py", line 2034, in
process_node
replacements = lopt.transform(node)
File "/home/granger/dev/Theano/theano/tensor/opt.py", line 4989, in
transform
num, denum = self.simplify(list(orig_num), list(orig_denum), out.type)
File "/home/granger/dev/Theano/theano/tensor/opt.py", line 4833, in
simplify
out_type=out_type)
File "/home/granger/dev/Theano/theano/tensor/opt.py", line 4919, in
simplify_constants
out_type=out_type)
File "/home/granger/dev/Theano/theano/tensor/opt.py", line 6328, in
add_calculate
v = reduce(np.add, num, zero) - reduce(np.add, denum, zero)
TypeError: numpy boolean subtract, the `-` operator, is deprecated, use
the bitwise_xor, the `^` operator, or the logical_xor function instead.
This error does not happen when running on CPU backend.
I suspect it might be due to the use of binary values in my code, but the
log message is not very helpful, is there any way to get some more
information to track down the error? Note that the fast_compile optimizer
does not trigger the error, only the fast_run one.

A demo code and the complete output is available here:
https://gist.github.com/nlgranger/279bda7fff356cfe3f40ad6397d0ba04

Best,
Nicolas
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Frédéric Bastien
2018-02-02 14:31:52 UTC
Permalink
Thanks for the report. Which version of numpy do you use?

The problem seem related to your numpy version from the error message.
Post by n***@gmail.com
Hi everyone,
While using an OpFromGraph involving some operations with binary values,
theano.gof.opt: ERROR: Optimization failure due to: local_add_canonizer
Elemwise{add,no_inplace}(InplaceDimShuffle{0,1,x}.0,
InplaceDimShuffle{x,0,1}.0)
File "/home/granger/dev/Theano/theano/gof/opt.py", line 2034, in
process_node
replacements = lopt.transform(node)
File "/home/granger/dev/Theano/theano/tensor/opt.py", line 4989, in
transform
num, denum = self.simplify(list(orig_num), list(orig_denum), out.type)
File "/home/granger/dev/Theano/theano/tensor/opt.py", line 4833, in
simplify
out_type=out_type)
File "/home/granger/dev/Theano/theano/tensor/opt.py", line 4919, in
simplify_constants
out_type=out_type)
File "/home/granger/dev/Theano/theano/tensor/opt.py", line 6328, in
add_calculate
v = reduce(np.add, num, zero) - reduce(np.add, denum, zero)
TypeError: numpy boolean subtract, the `-` operator, is deprecated, use
the bitwise_xor, the `^` operator, or the logical_xor function instead.
This error does not happen when running on CPU backend.
I suspect it might be due to the use of binary values in my code, but the
log message is not very helpful, is there any way to get some more
information to track down the error? Note that the fast_compile optimizer
does not trigger the error, only the fast_run one.
https://gist.github.com/nlgranger/279bda7fff356cfe3f40ad6397d0ba04
Best,
Nicolas
--
---
You received this message because you are subscribed to the Google Groups
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
n***@gmail.com
2018-02-04 20:44:11 UTC
Permalink
I'm using numpy 1.14.0 from the popular conda-forge repository. BTW, I was
wrong with the GPU/CPU distinction: the errror is triggered in either case.
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Frédéric Bastien
2018-02-07 20:31:47 UTC
Permalink
I'm not able to reproduce it.

On which OS? Which Theano version? Can you try a Theano version at least
1.0.1?

You can ignore this "error". Mostly, some optimization are skipped. But I
would still like to fix it.

I ran the tests like this:

THEANO_FLAGS=device=cuda,floatX=float32 nosetests test_ctc.py &> OUT

What are your Theano flags?
Post by n***@gmail.com
Hi everyone,
While using an OpFromGraph involving some operations with binary values,
theano.gof.opt: ERROR: Optimization failure due to: local_add_canonizer
Elemwise{add,no_inplace}(InplaceDimShuffle{0,1,x}.0,
InplaceDimShuffle{x,0,1}.0)
File "/home/granger/dev/Theano/theano/gof/opt.py", line 2034, in
process_node
replacements = lopt.transform(node)
File "/home/granger/dev/Theano/theano/tensor/opt.py", line 4989, in
transform
num, denum = self.simplify(list(orig_num), list(orig_denum), out.type)
File "/home/granger/dev/Theano/theano/tensor/opt.py", line 4833, in
simplify
out_type=out_type)
File "/home/granger/dev/Theano/theano/tensor/opt.py", line 4919, in
simplify_constants
out_type=out_type)
File "/home/granger/dev/Theano/theano/tensor/opt.py", line 6328, in
add_calculate
v = reduce(np.add, num, zero) - reduce(np.add, denum, zero)
TypeError: numpy boolean subtract, the `-` operator, is deprecated, use
the bitwise_xor, the `^` operator, or the logical_xor function instead.
This error does not happen when running on CPU backend.
I suspect it might be due to the use of binary values in my code, but the
log message is not very helpful, is there any way to get some more
information to track down the error? Note that the fast_compile optimizer
does not trigger the error, only the fast_run one.
https://gist.github.com/nlgranger/279bda7fff356cfe3f40ad6397d0ba04
Best,
Nicolas
--
---
You received this message because you are subscribed to the Google Groups
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
n***@gmail.com
2018-02-13 15:38:30 UTC
Permalink
Sorry for the delay, I just re-ran it in a clean conda environnement, here
are my system specs:

OS: archlinux
nvidia: 390.25
cuda: 9.1.85
numpy: 1.14.0
pygpu: 0.7.5
theano: git master

.theanorc:
[global]
device = cuda
floatX = float32
warn_float64 = warn
on_opt_error = raise

[nvcc]
fastmath = True

[gpuarray]
preallocate = 0.85

[cuda]
include_path = /opt/cuda/include
library_path = /opt/cuda/lib64
Post by Frédéric Bastien
I'm not able to reproduce it.
On which OS? Which Theano version? Can you try a Theano version at least
1.0.1?
You can ignore this "error". Mostly, some optimization are skipped. But I
would still like to fix it.
THEANO_FLAGS=device=cuda,floatX=float32 nosetests test_ctc.py &> OUT
What are your Theano flags?
Post by n***@gmail.com
Hi everyone,
While using an OpFromGraph involving some operations with binary values,
theano.gof.opt: ERROR: Optimization failure due to: local_add_canonizer
Elemwise{add,no_inplace}(InplaceDimShuffle{0,1,x}.0,
InplaceDimShuffle{x,0,1}.0)
File "/home/granger/dev/Theano/theano/gof/opt.py", line 2034, in
process_node
replacements = lopt.transform(node)
File "/home/granger/dev/Theano/theano/tensor/opt.py", line 4989, in
transform
num, denum = self.simplify(list(orig_num), list(orig_denum), out.type)
File "/home/granger/dev/Theano/theano/tensor/opt.py", line 4833, in
simplify
out_type=out_type)
File "/home/granger/dev/Theano/theano/tensor/opt.py", line 4919, in
simplify_constants
out_type=out_type)
File "/home/granger/dev/Theano/theano/tensor/opt.py", line 6328, in
add_calculate
v = reduce(np.add, num, zero) - reduce(np.add, denum, zero)
TypeError: numpy boolean subtract, the `-` operator, is deprecated, use
the bitwise_xor, the `^` operator, or the logical_xor function instead.
This error does not happen when running on CPU backend.
I suspect it might be due to the use of binary values in my code, but the
log message is not very helpful, is there any way to get some more
information to track down the error? Note that the fast_compile optimizer
does not trigger the error, only the fast_run one.
https://gist.github.com/nlgranger/279bda7fff356cfe3f40ad6397d0ba04
Best,
Nicolas
--
---
You received this message because you are subscribed to the Google Groups
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...