GithubHelp home page GithubHelp logo

Comments (4)

dfalbel avatar dfalbel commented on September 24, 2024 1

Thanks for the investigation @shikokuchuo ! This was really helpful! I think #1122 will fix it

from torch.

shikokuchuo avatar shikokuchuo commented on September 24, 2024

Breaking this down after further investigation:

The "y is not a torch_device" error is actually to do with the use of safetensors. If I set torch.serialization_version to 2 then things work as before. It points to this error occurring during loading of serialised tensors (model and optimiser) saved previously. I haven't had the time to figure out exactly where it happens, but it seems that this is a breaking change for existing code.

The second "length" error only happens within Rstudio, I'm guessing as it automatically tries to determine it's length for the environment pane or something. More of a cosmetic issue.

from torch.

shikokuchuo avatar shikokuchuo commented on September 24, 2024

Thanks I see you've addressed the second point already.

I've pinpointed the first issue. It seems that the 'device' argument of safetensors::safe_load() only takes a character string and not a torch device already created with torch_device().

Specifically where this was causing an issue was with loading of an optimizer state dict to the correct device, in the context of something like the code below:

device <- torch_device("cuda:0")

net <- torch_load(modelfile)
net$to(device = device)$train()
optimiser <- optim_adam(net$parameters)
optimiser$load_state_dict(torch_load(optimfile, device = device))

This worked before, but now the second torch_load() fails, but works if torch_load(optimfile, device = "cuda:0") is specified instead.

from torch.

shikokuchuo avatar shikokuchuo commented on September 24, 2024

Thanks, can confirm this fixes the issue.

from torch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.