Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cryptic error in Flux#zygote "Can't differentiate foreigncall expression" #817

Closed
mbeltagy opened this issue Jul 26, 2019 · 3 comments
Closed

Comments

@mbeltagy
Copy link

mbeltagy commented Jul 26, 2019

We (@metanoid and I) were trying to see if can get the char-rnn example to work

We modified
https://github.com/FluxML/model-zoo/blob/zygote/text/char-rnn/char-rnn.jl#L32:L36
to

function loss(xs, ys)
  l = sum(crossentropy.(m.(gpu.(xs)), gpu.(ys)))
  return l
end

assuming that call to truncate! will not longer been needed since we no longer doing tracking.

We got this very strange error


Can't differentiate foreigncall expression
in top-level scope at base/none
in  at base/none
in #train!#12 at Flux/MBJYi/src/optimise/train.jl:67
in macro expansion at Juno/TfNYn/src/progress.jl:124 
in macro expansion at Flux/MBJYi/src/optimise/train.jl:69 
in gradient at Zygote/fuj2C/src/compiler/interface.jl:47
in  at Zygote/fuj2C/src/compiler/interface.jl:101
in  at Zygote/fuj2C/src/compiler/interface2.jl
in #14 at Flux/MBJYi/src/optimise/train.jl:70 
in  at Zygote/fuj2C/src/lib/grad.jl:46
in #135 at Zygote/fuj2C/src/lib/lib.jl:129 
in  at char-rnn.jl:33
in  at Zygote/fuj2C/src/compiler/interface2.jl
in broadcasted at base/broadcast.jl:1161 
in #260#back at Zygote/fuj2C/src/lib/grad.jl:46 
in #135 at Zygote/fuj2C/src/lib/lib.jl:129 
in #3049#back at Zygote/fuj2C/src/lib/grad.jl:46 
in  at Zygote/fuj2C/src/lib/broadcast.jl:113
in map at base/abstractarray.jl:2091 
in collect at base/array.jl:606
in iterate at base/generator.jl:47 
in #3 at base/generator.jl:36 
in #1182 at Zygote/fuj2C/src/lib/broadcast.jl:113 
in  at Zygote/fuj2C/src/compiler/interface2.jl
in gpu at Flux/MBJYi/src/treelike.jl:68 
in  at Zygote/fuj2C/src/compiler/interface2.jl
in mapleaves at Flux/MBJYi/src/treelike.jl:28 
in  at Zygote/fuj2C/src/compiler/interface2.jl
in #mapleaves#39 at Flux/MBJYi/src/treelike.jl:28 
in  at Zygote/fuj2C/src/compiler/interface2.jl
in haskey at base/abstractdict.jl:17 
in  at Zygote/fuj2C/src/compiler/interface2.jl
in in at base/abstractdict.jl:665 
in  at Zygote/fuj2C/src/compiler/interface2.jl
in get at base/abstractdict.jl:594 
in error at base/error.jl:33
@mbeltagy mbeltagy reopened this Jul 26, 2019
@bhvieira
Copy link
Contributor

Zygote is probably trying to differentiate something inside Cuda. Why do you need to call gpu inside loss?

@DhairyaLGandhi
Copy link
Member

I think this is a Julia 1.0 issue, and nothing we can do about it. There doesn't seem to be a problem otherwise, everything works as expected once the error is thrown

@ToucheSir
Copy link
Member

Julia 1.6 is the new LTS, and AFAIK the char-nn should work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants