Skip to content

Cannot install a version of tensorflow that allows me to use GPU #611

Description

@isaaceckert

Working on a Apple M1 Pro mac in RStudio. I can install everything fine but they tensorflow can't find any local GPUs so the models take a long time to fit.

For example,

library(tensorflow)
tf$config$list_physical_devices("GPU")

Give me:

list()

Session info and stuff below:

> reticulate::py_config()
python:         /Users/isaaceckert/.virtualenvs/r-tensorflow/bin/python
libpython:      /Users/isaaceckert/.pyenv/versions/3.10.15/lib/libpython3.10.dylib
pythonhome:     /Users/isaaceckert/.virtualenvs/r-tensorflow:/Users/isaaceckert/.virtualenvs/r-tensorflow
version:        3.10.15 (main, Nov 20 2024, 16:40:35) [Clang 16.0.0 (clang-1600.0.26.4)]
numpy:          /Users/isaaceckert/.virtualenvs/r-tensorflow/lib/python3.10/site-packages/numpy
numpy_version:  1.26.4
tensorflow:     /Users/isaaceckert/.virtualenvs/r-tensorflow/lib/python3.10/site-packages/tensorflow

NOTE: Python version was forced by VIRTUAL_ENV
> tensorflow::tf_config()
TensorFlow v2.15.1 (~/.virtualenvs/r-tensorflow/lib/python3.10/site-packages/tensorflow)
Python vError in cat("Python v", x$python_version, " (", aliased(x$python), ")\n",  : 
  argument 2 (type 'list') cannot be handled by 'cat'
> reticulate::import("tensorflow")
Module(tensorflow)
> reticulate::py_last_error()

── Python Exception Message ─────────────────────────────────────────────────────────────────────────────────────
AttributeError: partially initialized module 'tensorflow' has no attribute 'constant' (most likely due to a circular import)

── R Traceback ──────────────────────────────────────────────────────────────────────────────────────────────────
     ▆
  1. ├─tf$constant
  2. ├─reticulate:::`$.python.builtin.module`(tf, constant)
  3. │ └─reticulate::py_get_attr(x, name, TRUE)
  4. ├─reticulate (local) `<fn>`()
  5. │ └─reticulate::configure_environment()
  6. │   └─reticulate:::python_package_requirements(package)
  7. │     └─base::lapply(...)
  8. │       └─reticulate (local) FUN(X[[i]], ...)
  9. │         ├─base::tryCatch(...)
 10. │         │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
 11. │         │   └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 12. │         │     └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 13. │         └─reticulate:::python_package_requirements_find(package)
 14. │           └─base::system.file("DESCRIPTION", package = package)
 15. │             └─base::find.package(package, lib.loc, quiet = TRUE)
 16. │               └─base::apply(!is.na(db), 1L, all)
 17. ├─base::suppressWarnings(base::try(tf$constant, silent = TRUE))
 18. │ └─base::withCallingHandlers(...)
 19. ├─base::try(tf$constant, silent = TRUE)
 20. │ └─base::tryCatch(...)
 21. │   └─base (local) tryCatchList(expr, classes, parentenv, handlers)
 22. │     └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 23. │       └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 24. ├─tf$constant
 25. ├─reticulate:::`$.python.builtin.module`(tf, constant)
 26. │ └─reticulate::py_get_attr(x, name, TRUE)
 27. ├─reticulate (local) `<fn>`(`<python.builtin.module>`)
 28. │ ├─base::tryCatch(import(module), error = clear_error_handler())
 29. │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
 30. │ │   └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 31. │ │     └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 32. │ └─reticulate::import(module)
 33. │   └─reticulate:::py_module_import(module, convert = convert)
 34. ├─base::suppressWarnings(base::try(tf$constant, silent = TRUE))
 35. │ └─base::withCallingHandlers(...)
 36. ├─base::try(tf$constant, silent = TRUE)
 37. │ └─base::tryCatch(...)
 38. │   └─base (local) tryCatchList(expr, classes, parentenv, handlers)
 39. │     └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 40. │       └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 41. ├─tf$constant
 42. └─reticulate:::`$.python.builtin.module`(tf, constant)
 43.   └─reticulate::py_get_attr(x, name, FALSE)
See `reticulate::py_last_error()$r_trace$full_call` for more details.
> sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS 14.6.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/Toronto
tzcode source: internal

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

other attached packages:
[1] tensorflow_2.16.0.9000 keras_2.15.0          

loaded via a namespace (and not attached):
 [1] utf8_1.2.4        R6_2.5.1          base64enc_0.1-3   Matrix_1.6-1      lattice_0.21-8    reticulate_1.40.0
 [7] magrittr_2.0.3    rappdirs_0.3.3    glue_1.8.0        png_0.1-8         generics_0.1.3    lifecycle_1.0.4  
[13] cli_3.6.3         fansi_1.0.6       vctrs_0.6.5       grid_4.3.0        withr_3.0.2       zeallot_0.1.0    
[19] tfruns_1.5.3      compiler_4.3.0    rstudioapi_0.17.1 tools_4.3.0       whisker_0.4.1     pillar_1.9.0     
[25] Rcpp_1.0.13-1     rlang_1.1.4       jsonlite_1.8.9   

Any help is very much appreciated! Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions