mlverse / torchvision

R interface to torchvision
https://torchvision.mlverse.org
Other
62 stars 14 forks source link

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

Open dkibalnikov opened 1 year ago

dkibalnikov commented 1 year ago

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 commented 12 months ago

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 commented 11 months ago

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

RSchwinn commented 6 months ago

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 commented 6 months ago

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

dfalbel commented 6 months ago

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

TLDR the solution should be

install.packages("torchvision", type = "source")
RSchwinn commented 6 months ago

Yes! It works. I should have tried as much.

Rich

On Fri, Mar 1, 2024 at 9:16 AM Daniel Falbel @.***> wrote:

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")

— Reply to this email directly, view it on GitHub https://github.com/mlverse/torchvision/issues/100#issuecomment-1973282566, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADC6H5RWQ6WYVJXAEPSLEJLYWCESPAVCNFSM6AAAAAA3JXYI7GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZTGI4DENJWGY . You are receiving this because you commented.Message ID: @.***>