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

R session crashed #537

Closed
zhiiiyang opened this issue Jun 9, 2022 · 14 comments
Closed

R session crashed #537

zhiiiyang opened this issue Jun 9, 2022 · 14 comments

Comments

@zhiiiyang
Copy link

Hi, I followed the instructions in the issue demo. And the R session just crashed.

reticulate::py_config()
tensorflow::tf_config()
reticulate::import("tensorflow")
reticulate::py_last_error()
sessionInfo()

Screen Shot 2022-06-08 at 8 42 49 PM

@njtierney
Copy link

Just a note that I have directed @zhiiiyang here , from greta-dev/greta#526

@t-kalinowski
Copy link
Member

t-kalinowski commented Jun 9, 2022

Hi, thanks for reporting. I just looked over that thread, sorry you're encountering such persistent issues! My suspicion is that this is ultimately an M1 Mac installation issue. Does the same segfault happen outside the RStudio IDE, just running R in the terminal?

Many installation issues are resolved by running the following in a fresh R session (you can restart R in Rstudio with Ctrl+Shift+F10):

# install the development version of packages, in case the
# issue is already fixed but not on CRAN yet.
install.packages("remotes")
remotes::install_github(sprintf("rstudio/%s", c("reticulate", "tensorflow", "keras")))
reticulate::miniconda_uninstall() # start with a blank slate
reticulate::install_miniconda()
keras::install_keras()

Test to see if installation was successful.

tensorflow::as_tensor("Hello World")

If the above snippet succeeded and you saw something like tf.Tensor(b'Hello World', shape=(), dtype=string), then 🎉, you've successfully installed Tensorflow.

If the above installation failed, please gather some diagnostic info:

sessionInfo()
reticulate::py_config()
tensorflow::tf_config()
reticulate::import("tensorflow")
reticulate::py_last_error()

Please copy and paste the FULL OUTPUT of running all three snippets, and be sure to enclose the output lines with three backticks (```) for monospace formatting.

@zhiiiyang
Copy link
Author

@t-kalinowski Thank you so much for helping out. Yes, I am using an M1 Mac.

  1. It also resulted in errors using terminals too. Please see the screenshot below.
    Screen Shot 2022-06-09 at 6 15 51 PM

  2. It crashed after running tensorflow::as_tensor("Hello World")

Screen Shot 2022-06-09 at 6 19 08 PM

  1. Here is the screenshot after running the diagnostic code.
    Screen Shot 2022-06-09 at 6 20 06 PM

@t-kalinowski
Copy link
Member

Did you run this snippet as well?

reticulate::miniconda_uninstall() # start with a blank slate
reticulate::install_miniconda()

It looks like your miniconda installation path is missing the -arm64 suffix, suggesting that the x86 build of miniconda was installed instead of the arm64 build.

@zhiiiyang
Copy link
Author

@t-kalinowski here you go. The code has successfully installed minicoda. But it still has errors.

Screen Shot 2022-06-09 at 6 31 22 PM

As you can see, this is a note to run install_tensorflow. If I do it, it will result in the session crashing again by running the above code.

@t-kalinowski
Copy link
Member

Are you running the x86 build of R under Rosetta? In the earlier thread your sessionInfo() first said yes, then no, not it looks like you're maybe back on x86?

What is the output of sessionInfo()?

@t-kalinowski
Copy link
Member

t-kalinowski commented Jun 10, 2022

Also, do you maybe have two miniconda installations? Can you please share the output of list.files("~/Library", pattern = "miniconda", all.files = TRUE, full.names = TRUE)

@zhiiiyang
Copy link
Author

Here you go.

> list.files("~/Library", pattern = "miniconda", all.files = TRUE, full.names = TRUE)
[1] "/Users/zhiyang/Library/r-miniconda

@t-kalinowski
Copy link
Member

Sorry, can you please post the full output from the install instructions as I described in my first response on this issue?

@zhiiiyang
Copy link
Author

@t-kalinowski, sorry about the delayed response.

Here is the full output from sessionInfo().

R version 4.2.0 (2022-04-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.4

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/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     

loaded via a namespace (and not attached):
[1] compiler_4.2.0 tools_4.2.0   

@t-kalinowski
Copy link
Member

Hi @zhiiiyang, Can you please follow the full instructions I provided in this comment: #537 (comment)

Copy + paste the exact snippets into your R console and run them, and then copy + paste the entire console (inputs + outputs) into this issue.
Thank you!

@zhiiiyang
Copy link
Author

Hi @t-kalinowski, I see. Please the complete output below.

  1. Output from "Many installation issues are resolved by running the following in a fresh R session (you can restart R in Rstudio with Ctrl+Shift+F10)":
> remotes::install_github(sprintf("rstudio/%s", c("reticulate", "tensorflow", "keras")))
Skipping install of 'reticulate' from a github remote, the SHA1 (a4c7184f) has not changed since last install.
  Use `force = TRUE` to force installation
Downloading GitHub repo rstudio/tensorflow@HEAD
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?

1: All                             
2: CRAN packages only              
3: None                            
4: processx (3.5.3 -> 3.6.1) [CRAN]

Enter one or more numbers, or an empty line to skip updates: reticulate::miniconda_uninstall() # start with a blank slate
Enter one or more numbers, or an empty line to skip updates: reticulate::install_miniconda()
Enter one or more numbers, or an empty line to skip updates: keras::install_keras()
Enter one or more numbers, or an empty line to skip updates: 
✔  checking for file ‘/private/var/folders/7h/6rmwx4c51mvdkn0xwlbf3tsc0000gn/T/RtmpDPgGYm/remotesad486d86425e/rstudio-tensorflow-54dda37/DESCRIPTION’ ...
─  preparing ‘tensorflow’:
✔  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘tensorflow_2.9.0.9000.tar.gz’
   
* installing *source* package ‘tensorflow’ ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (tensorflow)
Skipping install of 'keras' from a github remote, the SHA1 (13ae6cf2) has not changed since last install.
  Use `force = TRUE` to force installation
  1. Output from running tensorflow::as_tensor("Hello World")
    Screen Shot 2022-06-17 at 1 26 04 PM

  2. It crashed again after running

sessionInfo()
reticulate::py_config()
tensorflow::tf_config()
reticulate::import("tensorflow")
reticulate::py_last_error()

Screen Shot 2022-06-17 at 1 26 46 PM

@t-kalinowski
Copy link
Member

t-kalinowski commented Jun 17, 2022

Are you on M1 Mac? If so, can you install the arm64 build of R?
It's the 2nd link at https://cran.r-project.org/bin/macosx/

@zhiiiyang
Copy link
Author

@t-kalinowski, it worked!

> tensorflow::as_tensor("Hello World")
Loaded Tensorflow version 2.9.2
Metal device set to: Apple M1

systemMemory: 8.00 GB
maxCacheSize: 2.67 GB

2022-06-17 15:58:08.108824: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:305] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
2022-06-17 15:58:08.108947: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:271] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>)
tf.Tensor(b'Hello World', shape=(), dtype=string)

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

3 participants