I encountered an issue when trying to load a saved model in Julia. Here is the code I used:
import BSON: @load,@save
using Flux
using CUDA
using cuDNN
using DataFrames
using CSV
severity_levels = ["A", "B", "C"]
model = Flux.Chain(
Conv((2, 2), 3 => 32, stride=2,relu),
Flux.BatchNorm(32),
Dropout(0.25),
Conv((2, 2), 32 => 64, stride=2,relu),
Flux.BatchNorm(64),
Dropout(0.25),
Conv((2, 2), 64 => 16, stride=2,relu),
Flux.BatchNorm(16),
Flux.flatten,
Dense(16 * 16^2, 150),
Dropout(0.5),
Dense(150, length(severity_levels) * 25),
Dropout(0.5),
softmax
) |> gpu
@save "savemodel.bson" model
After restarting Julia and loading the saved model with the following code:
import BSON: @load,@save
using Flux
using CUDA
using cuDNN
using DataFrames
using CSV
severity_levels = ["A", "B", "C"]
@load "savemodel.bson" model
I received the following error when trying to view the model:
julia> model
Chain(
Conv((2, 2), 3 => 32, relu, stride=2), # 416 parameters
Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x7fff65604f16 -- unknown function (ip: 00007fff65604f16)
in expression starting at none:0
unknown function (ip: 00007fff65604f16)
unknown function (ip: 00007fff6549e4c0)
cuStreamAttachMemAsync at C:\Windows\system32\DriverStore\FileRepository\nv_dispsig.inf_amd64_2a8379cc1977656a\nvcuda64.dll (unknown line)
macro expansion at C:\Users\40041\.julia\packages\CUDA\Tl08O\lib\utils\call.jl:218 [inlined]
unchecked_cuStreamQuery at C:\Users\40041\.julia\packages\CUDA\Tl08O\lib\cudadrv\libcuda.jl:4260 [inlined]
isdone at C:\Users\40041\.julia\packages\CUDA\Tl08O\lib\cudadrv\stream.jl:128 [inlined]
spinning_synchronization at C:\Users\40041\.julia\packages\CUDA\Tl08O\lib\cudadrv\synchronization.jl:79
#synchronize#1000 at C:\Users\40041\.julia\packages\CUDA\Tl08O\lib\cudadrv\synchronization.jl:198
synchronize at C:\Users\40041\.julia\packages\CUDA\Tl08O\lib\cudadrv\synchronization.jl:196 [inlined]
synchronize at C:\Users\40041\.julia\packages\CUDA\Tl08O\src\memory.jl:521 [inlined]
maybe_synchronize at C:\Users\40041\.julia\packages\CUDA\Tl08O\src\memory.jl:526 [inlined]
convert at C:\Users\40041\.julia\packages\CUDA\Tl08O\src\memory.jl:545
unsafe_convert at C:\Users\40041\.julia\packages\CUDA\Tl08O\src\array.jl:434 [inlined]
#pointer#1123 at C:\Users\40041\.julia\packages\CUDA\Tl08O\src\array.jl:392 [inlined]
pointer at C:\Users\40041\.julia\packages\CUDA\Tl08O\src\array.jl:384 [inlined]
pointer at C:\Users\40041\.julia\packages\CUDA\Tl08O\src\array.jl:384 [inlined]
unsafe_convert at C:\Users\40041\.julia\packages\CUDA\Tl08O\src\array.jl:454
adapt_storage at C:\Users\40041\.julia\packages\CUDA\Tl08O\src\compiler\execution.jl:162 [inlined]
adapt_structure at C:\Users\40041\.julia\packages\Adapt\7T9au\src\Adapt.jl:57 [inlined]
adapt at C:\Users\40041\.julia\packages\Adapt\7T9au\src\Adapt.jl:40 [inlined]
_adapt_tuple_structure at C:\Users\40041\.julia\packages\Adapt\7T9au\src\base.jl:17 [inlined]
adapt_structure at C:\Users\40041\.julia\packages\Adapt\7T9au\src\base.jl:9 [inlined]
adapt at C:\Users\40041\.julia\packages\Adapt\7T9au\src\Adapt.jl:40 [inlined]
adapt_structure at C:\Users\40041\.julia\packages\Adapt\7T9au\src\base.jl:61 [inlined]
adapt at C:\Users\40041\.julia\packages\Adapt\7T9au\src\Adapt.jl:40 [inlined]
cudaconvert at C:\Users\40041\.julia\packages\CUDA\Tl08O\src\compiler\execution.jl:198 [inlined]
map at .\tuple.jl:293 [inlined]
map at .\tuple.jl:294 [inlined]
map at .\tuple.jl:294 [inlined]
map at .\tuple.jl:294 [inlined]
map at .\tuple.jl:294 [inlined]
map at .\tuple.jl:294 [inlined]
macro expansion at C:\Users\40041\.julia\packages\CUDA\Tl08O\src\compiler\execution.jl:110 [inlined]
#mapreducedim!#1238 at C:\Users\40041\.julia\packages\CUDA\Tl08O\src\mapreduce.jl:234
mapreducedim! at C:\Users\40041\.julia\packages\CUDA\Tl08O\src\mapreduce.jl:169 [inlined]
#_mapreduce#42 at C:\Users\40041\.julia\packages\GPUArrays\bbZD0\src\host\mapreduce.jl:67
_mapreduce at C:\Users\40041\.julia\packages\GPUArrays\bbZD0\src\host\mapreduce.jl:33 [inlined]
#mapreduce#40 at C:\Users\40041\.julia\packages\GPUArrays\bbZD0\src\host\mapreduce.jl:28 [inlined]
mapreduce at C:\Users\40041\.julia\packages\GPUArrays\bbZD0\src\host\mapreduce.jl:28 [inlined]
any at C:\Users\40041\.julia\packages\GPUArrays\bbZD0\src\host\mapreduce.jl:80 [inlined]
_any at C:\Users\40041\.julia\packages\Flux\JKfiV\src\layers\show.jl:146 [inlined]
#155 at C:\Users\40041\.julia\packages\Flux\JKfiV\src\layers\show.jl:148
unknown function (ip: 0000028fbfca726b)
_any at .\reduce.jl:1220
unknown function (ip: 0000028fbfc86c90)
any at .\reduce.jl:1215
_any at C:\Users\40041\.julia\packages\Flux\JKfiV\src\layers\show.jl:148 [inlined]
_all at C:\Users\40041\.julia\packages\Flux\JKfiV\src\layers\show.jl:152
unknown function (ip: 0000028fbfc869f3)
_nan_show at C:\Users\40041\.julia\packages\Flux\JKfiV\src\layers\show.jl:135
_layer_show at C:\Users\40041\.julia\packages\Flux\JKfiV\src\layers\show.jl:101
_big_show at C:\Users\40041\.julia\packages\Flux\JKfiV\src\layers\show.jl:85 [inlined]
_big_show at C:\Users\40041\.julia\packages\Flux\JKfiV\src\layers\show.jl:85
unknown function (ip: 0000028fbfc7e4ba)
_big_show at C:\Users\40041\.julia\packages\Flux\JKfiV\src\layers\show.jl:43
_big_show at C:\Users\40041\.julia\packages\Flux\JKfiV\src\layers\show.jl:23 [inlined]
show at C:\Users\40041\.julia\packages\Flux\JKfiV\src\layers\show.jl:9
unknown function (ip: 0000028fbfc7daf3)
#55 at C:\workdir\usr\share\julia\stdlib\v1.10\REPL\src\REPL.jl:273
jfptr_YY.55_95749.1 at C:\Users\40041\AppData\Local\Programs\Julia-1.10.4\lib\julia\sys.dll (unknown line)
with_repl_linfo at C:\workdir\usr\share\julia\stdlib\v1.10\REPL\src\REPL.jl:569
jfptr_with_repl_linfo_95854.1 at C:\Users\40041\AppData\Local\Programs\Julia-1.10.4\lib\julia\sys.dll (unknown line)
display at C:\workdir\usr\share\julia\stdlib\v1.10\REPL\src\REPL.jl:259
display at C:\workdir\usr\share\julia\stdlib\v1.10\REPL\src\REPL.jl:278 [inlined]
display at .\multimedia.jl:340
jfptr_display_68496.1 at C:\Users\40041\AppData\Local\Programs\Julia-1.10.4\lib\julia\sys.dll (unknown line)
jl_apply at C:/workdir/src\julia.h:1982 [inlined]
jl_f__call_latest at C:/workdir/src\builtins.c:812
#invokelatest#2 at .\essentials.jl:892 [inlined]
invokelatest at .\essentials.jl:889 [inlined]
print_response at C:\workdir\usr\share\julia\stdlib\v1.10\REPL\src\REPL.jl:315
#57 at C:\workdir\usr\share\julia\stdlib\v1.10\REPL\src\REPL.jl:284
jfptr_YY.57_95779.1 at C:\Users\40041\AppData\Local\Programs\Julia-1.10.4\lib\julia\sys.dll (unknown line)
with_repl_linfo at C:\workdir\usr\share\julia\stdlib\v1.10\REPL\src\REPL.jl:569
jfptr_with_repl_linfo_95854.1 at C:\Users\40041\AppData\Local\Programs\Julia-1.10.4\lib\julia\sys.dll (unknown line)
print_response at C:\workdir\usr\share\julia\stdlib\v1.10\REPL\src\REPL.jl:282
do_respond at C:\workdir\usr\share\julia\stdlib\v1.10\REPL\src\REPL.jl:911
jfptr_do_respond_95928.1 at C:\Users\40041\AppData\Local\Programs\Julia-1.10.4\lib\julia\sys.dll (unknown line)
jl_apply at C:/workdir/src\julia.h:1982 [inlined]
jl_f__call_latest at C:/workdir/src\builtins.c:812
#invokelatest#2 at .\essentials.jl:892 [inlined]
invokelatest at .\essentials.jl:889 [inlined]
run_interface at C:\workdir\usr\share\julia\stdlib\v1.10\REPL\src\LineEdit.jl:2656
jfptr_run_interface_94683.1 at C:\Users\40041\AppData\Local\Programs\Julia-1.10.4\lib\julia\sys.dll (unknown line)
run_frontend at C:\workdir\usr\share\julia\stdlib\v1.10\REPL\src\REPL.jl:1312
#62 at C:\workdir\usr\share\julia\stdlib\v1.10\REPL\src\REPL.jl:386
jfptr_YY.62_95830.1 at C:\Users\40041\AppData\Local\Programs\Julia-1.10.4\lib\julia\sys.dll (unknown line)
jl_apply at C:/workdir/src\julia.h:1982 [inlined]
start_task at C:/workdir/src\task.c:1238
Allocations: 17485888 (Pool: 17470968; Big: 14920); GC: 21
here is my version and status
julia> versioninfo()
Julia Version 1.10.4
Commit 48d4fd4843 (2024-06-04 10:41 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 16 Γ AMD Ryzen 7 5700G with Radeon Graphics
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, znver3)
Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores)
julia> Pkg.status()
Status `C:\Users\40041\.julia\environments\v1.10\Project.toml`
[fbb218c0] BSON v0.3.9
[336ed68f] CSV v0.10.14
[052768ef] CUDA v5.4.3
β [13f3f980] CairoMakie v0.6.3
[e2e10f9a] CatBoost v0.3.5
[324d7699] CategoricalArrays v0.10.8
[5ae59095] Colors v0.12.11
[992eb4ea] CondaPkg v0.2.23
[a93c6f00] DataFrames v1.6.1
[5721bf48] DataVoyager v1.1.0
[7db386b5] DependencyWalker v0.1.2
[c87230d0] FFMPEG v0.4.1
β [587475ba] Flux v0.14.17
[38e38edf] GLM v1.9.0
[dc211083] Gnuplot v1.6.5
[916415d5] Images v0.26.1
[cc2ba9b6] MLDataUtils v0.5.4
[c6f25543] MLJDecisionTreeInterface v0.4.2
[6ee0df7b] MLJLinearModels v0.10.0
[5ae90465] MLJScikitLearnInterface v0.7.0
[6f286f6a] MultivariateStats v0.10.3
[8b842266] PalmerPenguins v0.1.4
[ef544631] Pipelines v0.10.6
[14b8a8f1] PkgTemplates v0.7.51
[a03496cd] PlotlyBase v0.8.19
[91a5bcdd] Plots v1.40.5
[c3e4b0f8] Pluto v0.19.45
[438e738f] PyCall v1.96.4
[ce6b1742] RDatasets v0.7.7
[e4f92426] ROC v0.1.0 `https://github.com/diegozea/ROC.jl#master`
[321657f4] ScientificTypes v3.0.2
[3646fa90] ScikitLearn v0.7.0
[860ef19b] StableRNGs v1.0.2
β
[2913bbd2] StatsBase v0.33.21
[f3b207a7] StatsPlots v0.15.7
[bd369af6] Tables v1.12.0
[b189fb0b] ThreadPools v2.1.1
β [f0413319] Tidier v0.7.7
[a759f4b9] TimerOutputs v0.5.24
[0ae4a718] VegaDatasets v2.1.1
[112f6efa] VegaLite v3.3.0
[02a925ec] cuDNN v1.3.2
Info Packages marked with β and β
have new versions available. Those with β may be upgradable, but those with β
are restricted by compatibility constraints from upgrading. To see why use `status --outdated`
Could this issue be related to the way the model is being saved or loaded? Any help or suggestions would be greatly appreciated.