# Troubles with 'train!' under Flux.jl whilst using 'Chain' function

**URL:** https://discourse.julialang.org/t/troubles-with-train-under-flux-jl-whilst-using-chain-function/75834
**Category:** Package Management
**Tags:** flux, chainrulescore
**Created:** [February 5, 2022, 12:27am UTC](https://discourse.julialang.org/t/troubles-with-train-under-flux-jl-whilst-using-chain-function/75834 "2022-02-05T00:27:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ashish.pujari](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ashish.pujari/32/33522_2.png) [@ashish.pujari](https://discourse.julialang.org/u/ashish.pujari)
#### Post date: [February 5, 2022, 12:27am UTC](https://discourse.julialang.org/t/troubles-with-train-under-flux-jl-whilst-using-chain-function/75834/1 "2022-02-05T00:27:49Z")

</div>

I am new to Flux.jl and its application in the domain of Deep Learning. Running the introductory code (provided at [Overview · Flux](https://fluxml.ai/Flux.jl/stable/models/overview/)) seems to do a good job of showcasing Flux’s abilities.

The issue starts when I replace the model with multiple fully connected layers using ‘Chain’. For eg:

model = Chain(Dense(1, 1,relu),Dense(1,1))

The following error arises when I try and train the model:

MethodError: no method matching ChainRulesCore.InplaceableThunk(::NNlib.var"#32#35"{Matrix{Float32}, Matrix{Float32}}, ::ChainRulesCore.Thunk{NNlib.var"#33#36"{Matrix{Float32}, Matrix{Float32}}})  
Closest candidates are:  
ChainRulesCore.InplaceableThunk(::T, ::F) where {T\<:ChainRulesCore.Thunk, F} at C:\Users\apujari1.julia\packages\ChainRulesCore\qbmEe\src\differentials\thunks.jl:116

I do not seem to be able to figure out what could be causing such an issue. Currently, I am using Julia 1.6.1.

I would highly appreciate an insight.

PS: Updating packages using Pkg.update() seem to have done nothing.

---

<div class="post-metadata">

### Author: ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)
#### Post date: [February 5, 2022, 2:47am UTC](https://discourse.julialang.org/t/troubles-with-train-under-flux-jl-whilst-using-chain-function/75834/2 "2022-02-05T02:47:48Z")

</div>

From the error message it looks like you might have a very old version of ChainRulesCore somehow, this signature was changed [here](https://github.com/JuliaDiff/ChainRulesCore.jl/pull/396) last July, v0.10.

You can try `] add ChainRulesCore@1.12.0` to force an update, which if it fails may print something telling you (or telling someone here!) what other package is holding this back, if that is what’s happening.

---

<div class="post-metadata">

### Author: ![ashish.pujari](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ashish.pujari/32/33522_2.png) [@ashish.pujari](https://discourse.julialang.org/u/ashish.pujari)
#### Post date: [February 5, 2022, 6:49pm UTC](https://discourse.julialang.org/t/troubles-with-train-under-flux-jl-whilst-using-chain-function/75834/3 "2022-02-05T18:49:11Z")

</div>

Thank you for your response. Forcing an update provides the following error:

Unsatisfiable requirements detected for package IterativeSolvers [42fd0dbc]:  
IterativeSolvers [42fd0dbc] log:  
├─possible versions are: 0.7.0-0.9.2 or uninstalled  
├─restricted by compatibility requirements with ConstrainedSystems [c257ce95] to versions: 0.8.0-0.8.5  
│ └─ConstrainedSystems [c257ce95] log:  
│ ├─possible versions are: 0.1.0-0.2.7 or uninstalled  
│ └─restricted to versions 0.1.2-0.1 by ViscousStreaming [47fb7046], leaving only versions 0.1.2  
│ └─ViscousStreaming [47fb7046] log:  
│ ├─possible versions are: 0.1.0 or uninstalled  
│ └─ViscousStreaming [47fb7046] is fixed to version 0.1.0  
└─restricted by compatibility requirements with DiffEqBase [2b5f629d] to versions: 0.9.0-0.9.2 — no versions left  
└─DiffEqBase [2b5f629d] log:  
├─possible versions are: 3.13.2-6.81.3 or uninstalled  
├─restricted by compatibility requirements with Reexport [189a3867] to versions: [3.13.2-6.53.6, 6.57.0-6.81.3] or uninstalled  
│ └─Reexport [189a3867] log:  
│ ├─possible versions are: 0.2.0-1.2.2 or uninstalled  
│ └─restricted to versions 0.2 by ViscousStreaming [47fb7046], leaving only versions 0.2.0  
│ └─ViscousStreaming [47fb7046] log: see above  
├─restricted by compatibility requirements with ChainRulesCore [d360d2e6] to versions: [3.13.2-6.10.0, 6.59.1, 6.69.0-6.81.3] or uninstalled  
│ └─ChainRulesCore [d360d2e6] log:  
│ ├─possible versions are: 0.1.0-1.12.0 or uninstalled  
│ └─restricted to versions 1.12.0 by an explicit requirement, leaving only versions 1.12.0  
└─restricted by compatibility requirements with DiffEqCallbacks [459566f4] to versions: 6.11.0-6.81.3, leaving only versions: [6.59.1, 6.69.0-6.81.3]  
└─DiffEqCallbacks [459566f4] log:  
├─possible versions are: 2.0.0-2.20.1 or uninstalled  
└─restricted to versions 2.14.0-2 by ViscousStreaming [47fb7046], leaving only versions 2.14.0-2.20.1  
└─ViscousStreaming [47fb7046] log: see above

Stacktrace:  
[1] propagate\_constraints!(graph::Pkg.Resolve.Graph, sources::Set{Int64}; log\_events::Bool)  
@ Pkg.Resolve C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Resolve\graphtype.jl:1048  
[2] propagate\_constraints! (repeats 2 times)  
@ C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Resolve\graphtype.jl:989 [inlined]  
[3] simplify\_graph!(graph::Pkg.Resolve.Graph, sources::Set{Int64}; clean\_graph::Bool)  
@ Pkg.Resolve C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Resolve\graphtype.jl:1503  
[4] simplify\_graph! (repeats 2 times)  
@ C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Resolve\graphtype.jl:1503 [inlined]  
[5] resolve\_versions!(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec})  
@ Pkg.Operations C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:405  
[6] targeted\_resolve(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}, preserve::Pkg.Types.PreserveLevel)  
@ Pkg.Operations C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1210  
[7] tiered\_resolve(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec})  
@ Pkg.Operations C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1196  
[8] \_resolve  
@ C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1216 [inlined]  
[9] add(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}, new\_git::Vector{Base.UUID}; preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform)  
@ Pkg.Operations C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1231  
[10] add(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform, kwargs::Base.Iterators.Pairs{Symbol, IOContext{IOStream}, Tuple{Symbol}, NamedTuple{(:io,), Tuple{IOContext{IOStream}}}})  
@ Pkg.API C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:203  
[11] add(pkgs::Vector{Pkg.Types.PackageSpec}; io::IOContext{IOStream}, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})  
@ Pkg.API C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:79  
[12] add(pkgs::Vector{Pkg.Types.PackageSpec})  
@ Pkg.API C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:77  
[13] do\_cmd!(command::Pkg.REPLMode.Command, repl::IJulia.MiniREPL)  
@ Pkg.REPLMode C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\REPLMode\REPLMode.jl:408  
[14] do\_cmd(repl::IJulia.MiniREPL, input::String; do\_rethrow::Bool)  
@ Pkg.REPLMode C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\REPLMode\REPLMode.jl:386  
[15] top-level scope  
@ In[2]:1  
[16] eval  
@ .\boot.jl:360 [inlined]  
[17] include\_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)  
@ Base .\loading.jl:1094

---

<div class="post-metadata">

### Author: ![ashish.pujari](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ashish.pujari/32/33522_2.png) [@ashish.pujari](https://discourse.julialang.org/u/ashish.pujari)
#### Post date: [February 5, 2022, 7:49pm UTC](https://discourse.julialang.org/t/troubles-with-train-under-flux-jl-whilst-using-chain-function/75834/4 "2022-02-05T19:49:18Z")

</div>

I think the issue is with ViscousStreaming.jl installing sub-packages, versions of which cause a mismatch with sub-packages installed using ] add Flux. Otherwise, ] add ChainRulesCore@1.12.0 successfully forces an update and primary error ceases to exist.
