# \#bson

**URL:** https://discourse.julialang.org/tag/bson/258.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Saving and loading architectures with multiple blocks](https://discourse.julialang.org/t/saving-and-loading-architectures-with-multiple-blocks/104030)

<div class="topic-metadata">

**Author:** [@tom-plaa](https://discourse.julialang.org/u/tom-plaa)\
**Replies:** 3\
**Last updated:** [September 20, 2023, 3:49pm UTC](https://discourse.julialang.org/t/saving-and-loading-architectures-with-multiple-blocks/104030 "2023-09-20T15:49:25Z")

</div>

Hi! I’m working on a project where another person has been trying out different architectures in Flux.jl for a given problem, and the one that turned out to be the best one is giving us problems when saving and loading …

---

## [Problems with BSON](https://discourse.julialang.org/t/problems-with-bson/103150)

<div class="topic-metadata">

**Author:** [@Euhan](https://discourse.julialang.org/u/Euhan)\
**Replies:** 1\
**Last updated:** [August 28, 2023, 12:06pm UTC](https://discourse.julialang.org/t/problems-with-bson/103150 "2023-08-28T12:06:42Z")

</div>

This has been discussed before, but I can’t say that I have fully understood all intricacies of the problem. I try to load an object (flux model) with BSON.@load "/pathy/path" model. I have also tried to load it with bs…

---

## [BSON.load(filename,@\_\_MODULE\_\_) doesn't work inside a Test Module](https://discourse.julialang.org/t/bson-load-filename-module-doesnt-work-inside-a-test-module/100955)

<div class="topic-metadata">

**Author:** [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Replies:** 0\
**Last updated:** [June 29, 2023, 12:41am UTC](https://discourse.julialang.org/t/bson-load-filename-module-doesnt-work-inside-a-test-module/100955 "2023-06-29T00:41:18Z")

</div>

I have a Module. Inside that module I have a BSON.@save and a BSON.load which takes care of saving a struct to and from disk. The function that calls the BSON.load(filename,@MODULE) works fine if called by REPL/Main, o…

---

## [Problem loading saved neural network](https://discourse.julialang.org/t/problem-loading-saved-neural-network/98882)

<div class="topic-metadata">

**Author:** [@LucasMSpereira](https://discourse.julialang.org/u/LucasMSpereira)\
**Replies:** 9\
**Last updated:** [May 16, 2023, 4:09pm UTC](https://discourse.julialang.org/t/problem-loading-saved-neural-network/98882 "2023-05-16T16:09:46Z")

</div>

When trying to load a saved Flux NN with BSON.@load datasetPath \* "trainedNetworks/convnextGen.bson" cpuGenerator I’m getting a invalid struct allocation error. Since doing this last time, the only thing I did was upd…

---

## [What to do about models not loading in Flux? Critical breakage](https://discourse.julialang.org/t/what-to-do-about-models-not-loading-in-flux-critical-breakage/97881)

<div class="topic-metadata">

**Author:** [@Euhan](https://discourse.julialang.org/u/Euhan)\
**Replies:** 3\
**Last updated:** [May 3, 2023, 4:48pm UTC](https://discourse.julialang.org/t/what-to-do-about-models-not-loading-in-flux-critical-breakage/97881 "2023-05-03T16:48:26Z")

</div>

I use Flux to make ML models as part of my graduate studies. I read some time ago that you couldn’t trust model’s saved in bson-format, so I made a solution where I would recreate the model by dynamic loading (facing eno…

---

## [Error loading model parameters with BSON](https://discourse.julialang.org/t/error-loading-model-parameters-with-bson/96136)

<div class="topic-metadata">

**Author:** [@JuliaQ123](https://discourse.julialang.org/u/JuliaQ123)\
**Replies:** 1\
**Last updated:** [March 17, 2023, 8:17am UTC](https://discourse.julialang.org/t/error-loading-model-parameters-with-bson/96136 "2023-03-17T08:17:36Z")

</div>

I’m running into an error when trying to load saved model parameters using BSON. I am saving the model parameters with @save model\_path model\_params\_save and then trying to load them as per the examples with @load mod…

---

## [Error on load DataFrame with BSON](https://discourse.julialang.org/t/error-on-load-dataframe-with-bson/95634)

<div class="topic-metadata">

**Author:** [@rodolforbcoutinho](https://discourse.julialang.org/u/rodolforbcoutinho)\
**Replies:** 1\
**Last updated:** [March 6, 2023, 8:29pm UTC](https://discourse.julialang.org/t/error-on-load-dataframe-with-bson/95634 "2023-03-06T20:29:11Z")

</div>

Hello all! I’m getting an odd erro when loading a file with BSON. This file was created by other project/enviroment. I’m using and outdated enviroment now because I want to use SOM.jl ERROR: BoundsError: attempt to acc…

---

## [How to load BSON file of the model build with Flux@0.12.10 to use with Flux@0.13? Flux.Diagonal deprecated problem](https://discourse.julialang.org/t/how-to-load-bson-file-of-the-model-build-with-flux-0-12-10-to-use-with-flux-0-13-flux-diagonal-deprecated-problem/91588)

<div class="topic-metadata">

**Author:** [@Maxim\_Lubov](https://discourse.julialang.org/u/Maxim_Lubov)\
**Replies:** 7\
**Last updated:** [December 27, 2022, 4:24pm UTC](https://discourse.julialang.org/t/how-to-load-bson-file-of-the-model-build-with-flux-0-12-10-to-use-with-flux-0-13-flux-diagonal-deprecated-problem/91588 "2022-12-27T16:24:02Z")

</div>

I have a Transformer model that was built using Transformers.jl and Flux@0.12.10. After training the model, I saved it using BSON. Since Flux@0.13, Flux.Diagonal is deprecated and when I try to load model using BSON an…

---

## [BSON: Loading package artifacts that are typed by package itself](https://discourse.julialang.org/t/bson-loading-package-artifacts-that-are-typed-by-package-itself/84791)

<div class="topic-metadata">

**Author:** [@pat-alt](https://discourse.julialang.org/u/pat-alt)\
**Replies:** 2\
**Last updated:** [July 26, 2022, 6:47am UTC](https://discourse.julialang.org/t/bson-loading-package-artifacts-that-are-typed-by-package-itself/84791 "2022-07-26T06:47:56Z")

</div>

… struggling to even phrase that title properly, so I’m probably doing something silly :frowning: I’m relying on BSON to store some objects created and typed by my own package MyPkg as artifacts: BSON.@save path some\_ob…

---

## [StaticArrays 1.5, StaticArraysCore and BSON.jl](https://discourse.julialang.org/t/staticarrays-1-5-staticarrayscore-and-bson-jl/84473)

<div class="topic-metadata">

**Author:** [@josuagrw](https://discourse.julialang.org/u/josuagrw)\
**Replies:** 2\
**Last updated:** [July 21, 2022, 12:46pm UTC](https://discourse.julialang.org/t/staticarrays-1-5-staticarrayscore-and-bson-jl/84473 "2022-07-21T12:46:55Z")

</div>

What is the correct way to save and load StaticArrays in package version 1.5? Basically, I used to be able to import using StaticArrays using BSON and storing/loading worked fine. Now the code above works for storing…

---

## [BSON error when loading Flux model](https://discourse.julialang.org/t/bson-error-when-loading-flux-model/78085)

<div class="topic-metadata">

**Author:** [@luciano-drozda](https://discourse.julialang.org/u/luciano-drozda)\
**Replies:** 7\
**Last updated:** [March 19, 2022, 4:53pm UTC](https://discourse.julialang.org/t/bson-error-when-loading-flux-model/78085 "2022-03-19T16:53:42Z")

</div>

The command m = BSON.load("model.bson", @\_\_MODULE\_\_)\[:m\] is throwing ERROR: MethodError: Cannot \`convert\` an object of type CuContext to an object of type CuPtr{Nothing} Closest candidates are: convert(::Type{CuPtr{…

---

## [Optional field in struct](https://discourse.julialang.org/t/optional-field-in-struct/73338)

<div class="topic-metadata">

**Author:** [@Handam](https://discourse.julialang.org/u/Handam)\
**Replies:** 3\
**Last updated:** [December 20, 2021, 11:33pm UTC](https://discourse.julialang.org/t/optional-field-in-struct/73338 "2021-12-20T23:33:14Z")

</div>

Hi, if I have defined a struct, e.g. mutable struct A a::Tuple end and then saved an object of this struct with BSON o = A((1,2)) BSON.@save "o.bson" o is it then possible to add “optional” fields to the struct …

---

## [\[ANN\] LightBSON.jl](https://discourse.julialang.org/t/ann-lightbson-jl/67437)

<div class="topic-metadata">

**Author:** [@Christian\_Rorvik](https://discourse.julialang.org/u/Christian_Rorvik)\
**Replies:** 10\
**Last updated:** [September 10, 2021, 6:28am UTC](https://discourse.julialang.org/t/ann-lightbson-jl/67437 "2021-09-10T06:28:59Z")

</div>

Borne out of a need for high performance and allocation free BSON processing, announcing LightBSON.jl. What It Is Allocation free API for reading and writing BSON data. Natural mapping of Julia types to corresponding B…

---

## [Loading individual entries from BSON ignoring all others](https://discourse.julialang.org/t/loading-individual-entries-from-bson-ignoring-all-others/67660)

<div class="topic-metadata">

**Author:** [@crinders](https://discourse.julialang.org/u/crinders)\
**Replies:** 0\
**Last updated:** [September 3, 2021, 5:37pm UTC](https://discourse.julialang.org/t/loading-individual-entries-from-bson-ignoring-all-others/67660 "2021-09-03T17:37:05Z")

</div>

I’ve been using BSON to save my data. I’m using Turing and saved a BNN model. I tried to save the model, but I can’t reload it without explicitly using every dependent package utilized and finally some function for VarNa…

---

## [Unable to save and load model (or parameters) with BSON either on GPU or CPU](https://discourse.julialang.org/t/unable-to-save-and-load-model-or-parameters-with-bson-either-on-gpu-or-cpu/64582)

<div class="topic-metadata">

**Author:** [@sguns](https://discourse.julialang.org/u/sguns)\
**Replies:** 2\
**Last updated:** [July 15, 2021, 2:17am UTC](https://discourse.julialang.org/t/unable-to-save-and-load-model-or-parameters-with-bson-either-on-gpu-or-cpu/64582 "2021-07-15T02:17:50Z")

</div>

Hi, I’m training a model on GPU and trying to save intermediate states to disk as described in the Flux docs. Unfortunately it seems like the information about saving GPU models (in the blue box) is wrong - although I c…

---

## [World Age Errors while using BSON to store solution of a Differential Equation](https://discourse.julialang.org/t/world-age-errors-while-using-bson-to-store-solution-of-a-differential-equation/63305)

<div class="topic-metadata">

**Author:** [@Vivek\_Lohani](https://discourse.julialang.org/u/Vivek_Lohani)\
**Replies:** 2\
**Last updated:** [June 21, 2021, 10:33pm UTC](https://discourse.julialang.org/t/world-age-errors-while-using-bson-to-store-solution-of-a-differential-equation/63305 "2021-06-21T22:33:12Z")

</div>

I use the DifferentialEquations.jl package to solve for the evolution of multiple coupled differential equations by making use of several helper functions. Thereafter, I store the solution using BSON. Then I load the st…

---

## [Send BSON serialized data to a pipe](https://discourse.julialang.org/t/send-bson-serialized-data-to-a-pipe/62381)

<div class="topic-metadata">

**Author:** [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Replies:** 1\
**Last updated:** [June 4, 2021, 10:35am UTC](https://discourse.julialang.org/t/send-bson-serialized-data-to-a-pipe/62381 "2021-06-04T10:35:13Z")

</div>

Is there a way to send BSON serialized data to a pipe ? Writing a BSON to a file can be done with e.g. using BSON arr = \<somearray\> fname = tempname() BSON.bson(fname, data = arr) arr2 = BSON.load(fname)\[:data\] rm(fnam…

---

## [Add object to existing BSON file?](https://discourse.julialang.org/t/add-object-to-existing-bson-file/41305)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 1\
**Last updated:** [June 13, 2020, 1:44am UTC](https://discourse.julialang.org/t/add-object-to-existing-bson-file/41305 "2020-06-13T01:44:25Z")

</div>

Suppose I saved a BSON file with BSON.@save "path/to/file.bson" obj1 obj2 . Then later on I create a new obj3 and I want to also add to this file, as if I had executed BSON.@save "path/to/file.bson" obj1 obj2 obj3 …

---

## [Flux cannot save a parameters](https://discourse.julialang.org/t/flux-cannot-save-a-parameters/35642)

<div class="topic-metadata">

**Author:** [@Owolf](https://discourse.julialang.org/u/Owolf)\
**Replies:** 3\
**Last updated:** [March 16, 2020, 4:35pm UTC](https://discourse.julialang.org/t/flux-cannot-save-a-parameters/35642 "2020-03-16T16:35:30Z")

</div>

Dear Julia community, I am trying to save parameters for trained RNN with BSON. However it seems that in latest version of FLUX this is not possible, however https://fluxml.ai says something different. I create rnn as: …

---

## ["The applicable method may be too new" - Inference by loading saved BSON Flux model](https://discourse.julialang.org/t/the-applicable-method-may-be-too-new-inference-by-loading-saved-bson-flux-model/33913)

<div class="topic-metadata">

**Author:** [@jchen975](https://discourse.julialang.org/u/jchen975)\
**Replies:** 1\
**Last updated:** [March 4, 2020, 11:47am UTC](https://discourse.julialang.org/t/the-applicable-method-may-be-too-new-inference-by-loading-saved-bson-flux-model/33913 "2020-03-04T11:47:37Z")

</div>

Hi, I was trying to do inference with a previously trained Flux CNN that was saved with BSON with the following: 38 @load model\_name model 39 model = model |\> gpu 40 data = data |\> gpu 41 42 println(type…

---

## [Status of libraries for saving binary files: composite datatypes](https://discourse.julialang.org/t/status-of-libraries-for-saving-binary-files-composite-datatypes/34809)

<div class="topic-metadata">

**Author:** [@fipelle](https://discourse.julialang.org/u/fipelle)\
**Replies:** 2\
**Last updated:** [February 18, 2020, 2:16pm UTC](https://discourse.julialang.org/t/status-of-libraries-for-saving-binary-files-composite-datatypes/34809 "2020-02-18T14:16:29Z")

</div>

Hi, I am having some serious trouble saving composite datatypes. For small output files, BSON works fine. However, in cases where it is hard to split the output into many chunks, I tried to use JLD2. Unfortunately, thi…

---

## [Flux save and load models, BSON file](https://discourse.julialang.org/t/flux-save-and-load-models-bson-file/25310)

<div class="topic-metadata">

**Author:** [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Replies:** 2\
**Last updated:** [June 14, 2019, 8:04pm UTC](https://discourse.julialang.org/t/flux-save-and-load-models-bson-file/25310 "2019-06-14T20:04:10Z")

</div>

The question is: How to save and load more than one model into a single \*.BSON file? It’s even possible? @MikeInnes Cheers!
