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

Any launching of model_resnet functions throws error "Error in !self$..refer_to_state_dict.. : invalid argument type" #100

Open
dkibalnikov opened this issue Aug 9, 2023 · 6 comments

Comments

@dkibalnikov
Copy link

Any launching of model_resnet functions throws error "Error in !self$..refer_to_state_dict.. : invalid argument type"
Seems like some piece of reference information is missed in models.

@neelroop
Copy link

Hi, I'm curious if this issue was addressed? Perhaps elsewhere? I am having the same issue. Some details on the R session:

> torchvision::model_resnet18(pretrained = TRUE)
Error in !self$..refer_to_state_dict.. : invalid argument type
> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.5.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] luz_0.4.0              torchvision_0.5.1.9000 torch_0.11.0          

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.10       rstudioapi_0.14   magrittr_2.0.3    rappdirs_0.3.3    hms_1.1.2         progress_1.2.2    bit_4.0.5        
 [8] R6_2.5.1          rlang_1.1.1       tools_4.2.2       coro_1.0.3        cli_3.4.1         withr_2.5.0       remotes_2.4.2    
[15] ellipsis_0.3.2    bit64_4.0.5       lifecycle_1.0.3   crayon_1.5.2      processx_3.8.0    purrr_0.3.5       callr_3.7.3      
[22] vctrs_0.5.1       fs_1.5.2          ps_1.7.2          curl_4.3.3        zeallot_0.1.0     compiler_4.2.2    generics_0.1.3   
[29] prettyunits_1.1.1 pkgconfig_2.0.3 

@e-eight
Copy link

e-eight commented Sep 29, 2023

I am also having this issue, but only if I launch a resnet model with pretrained = TRUE.

@RSchwinn
Copy link

RSchwinn commented Feb 20, 2024

I am having exactly the same issue:

> resnet <- model_resnet18(pretrained = TRUE)
Error in !self$..refer_to_state_dict.. : invalid argument type


> sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.2.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] luz_0.4.0         torchvision_0.5.1 torch_0.12.0     

loaded via a namespace (and not attached):
 [1] coro_1.0.3        R6_2.5.1          bit_4.0.5         magrittr_2.0.3   
 [5] rappdirs_0.3.3    pkgconfig_2.0.3   generics_0.1.3    bit64_4.0.5      
 [9] lifecycle_1.0.4   ps_1.7.6          cli_3.6.2         processx_3.8.3   
[13] callr_3.7.5       vctrs_0.6.5       withr_3.0.0       zeallot_0.1.0    
[17] compiler_4.3.2    prettyunits_1.2.0 purrr_1.0.2       rstudioapi_0.15.0
[21] tools_4.3.2       hms_1.1.3         Rcpp_1.0.12       crayon_1.5.2     
[25] fs_1.6.3          rlang_1.1.3       progress_1.2.3   
> 

@dfalbel
Copy link
Member

dfalbel commented Mar 1, 2024

Sorry, I can't reproduce the issue. I wonder if re-installing torchvision can fix the problem?

@dfalbel
Copy link
Member

dfalbel commented Mar 1, 2024

So here's a way I could reproduce this issue:

  • Install an old torch version, eg remotes::install_version("torch", version="0.10.0")
  • Install torchvision
  • Loading the model works.
  • Update to a recent version. Breaks torchvision, loading no longer works
  • Re-Install torchvision from CRAN binaries. Doesn't work too
  • Install torchvision from source: install.packages("torchvision", type = "source") works.

TLDR the solution should be

install.packages("torchvision", type = "source")

@RSchwinn
Copy link

RSchwinn commented Mar 1, 2024 via email

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

5 participants