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

Types with CudaArray elements cannot be saved to JLD because of pointer exception #40

Open
denizyuret opened this issue Nov 12, 2015 · 3 comments

Comments

@denizyuret
Copy link
Contributor

I'd like to fix this so people can save and load machine learning models that use CudaArray's without having to explicitly copy everything to cpu. Is the right way to overwrite serialize - deserialize? Or is it to introduce a new cpu array type that CudaArrays know to convert themselves to and from during load/save? Or is there some other way?

@timholy
Copy link
Contributor

timholy commented Nov 12, 2015

@denizyuret
Copy link
Contributor Author

Thanks Tim, the following three lines solved the problem:

    type _CudaArraySave; a::Array; end
    JLD.writeas(c::CudaArray) = _CudaArraySave(to_host(c))
    JLD.readas(d::_CudaArraySave) = CudaArray(d.a)

Do you want to put this in CUDArt? I was going to submit a pull request but I couldn't be sure if you wanted JLD to be a requirement for CUDArt. In either case, this issue can be closed.

@timholy
Copy link
Contributor

timholy commented Dec 20, 2015

If you can come up with a solution that exploits Requires.jl, do you think that would be better?

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

2 participants