chainerx.array is not picklable
See original GitHub issueIt is often convenient if we can pickle chainerx arrays when we save/restore/communicate them.
>>> import pickle
>>> import chainerx as chx
>>> a = chx.array(10)
>>> a
array(10, shape=(), dtype=int64, device='native:0')
>>> pickle.dumps
<built-in function dumps>
>>> pickle.dumps(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: return_value_policy = copy, but the object is non-copyable!
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Object array is not picklable - python - Stack Overflow
Verifyed, pickle can handle object array given in Question. The following works without failure. pick_array = pickle.dumps(array) ...
Read more >ChainerX Tutorial — Chainer 7.8.1 documentation
Graph construction and backpropagation is built into the array, meaning that any function, including the NumPy-like functions, can be backpropagated through. In ...
Read more >Chainer v7.0.0a1 をリリースしました - Google Groups
Implement array vs array functionality to chainerx.minimum (#6541, thanks @aksub99!) ... Make InvalidType picklable (#6884, thanks @zaltoprofen!)
Read more >Python Examples of numpy - ProgramCreek.com
PZERO assert chainerx.e is numpy.e assert chainerx.euler_gamma is ... print 'cannot apply bellman_ford, graph is not oriented' return dist = np.array([np.
Read more >Qiitaのタグ一覧(アルファベット順)
... "ARR",E "array",C "array_multisort",E "ArrayList",D "arraymancer" ... "chainerRL",D "ChainerX",E "ChainOfResponsibility",E "ChakraCore" ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Introducing a Python wrapper class (#7983) does seem to fix the problem.
Now this variant works with the patch.
The problem seems to be this
py::return_value_policy::reference
, probably is setting something in the python side of the wrapper the first time the corresponding python object is created.A simple solution to this problem is to return the name of the device when serializing, and reconstruct the device from the name upon deserialization. I quickly tested this and worked. But if we can find a way to make the C++ to be directly pickable it will be better.