[R-sig-Debian] how to install R 4.4

ravi rv15| @end|ng |rom y@hoo@@e
Sat May 17 15:33:12 CEST 2025


Hi,
I am a rank beginner to all this, and all this is way above my depth. Very hesitantly, I am offering a solution.

I have worked with tensorflow on windows. I have learnt that the package is not compatible with the latest updates of python and other dependency packages. One solution is with the uv system and with the py_require() command which installs only those versions that are compatible. In R:

library(reticulate)
remotes::install_github("rstudio/tensorflow")
## try the same for keras
Sys.setenv("RETICULATE_PYTHON" = "managed") # this limits the versions that are compatible
reticulate::py_require(exclude_newer = "2025-03-11")
library(tensorflow)
tf$version$VERSION
#> [1] "2.18.0"
tf$constant("Hello World")
#> tf.Tensor(b'Hello World', shape=(), dtype=string)

Please try. No guarantee at all that this will work. Or even that it makes sense.
Cheers, Ravi



On Saturday, 17 May 2025 at 10:21:37 CEST, Dirk Eddelbuettel <edd using debian.org> wrote: 






Stephen,

On 16 May 2025 at 14:33, Stephen Bond wrote:
| Dirk,
| 
| I appreciate your help. Please, tell me what folders R installs into. I
| have a good working 4.3 on another box and want to copy over the 4.5 as
| this is my fastest box and it is a shame not to use it. 

That may be doable as a hack, but it is not recommended. See if an "apt
repackaging helper" exists.

| If you want to check your install of keras on 4.5 please, run the code
| below and confirm if it works and report on github. It should take
| under 1min.

I am traveling a continent over, and am a little pressed for time (and may
not have reticulate setup on the laptop I travel with). And as I mentioned,
this thread is getting a little astray of the initial question.

You work for one of the country's largest corporations, maybe your IT
department can help you with your particular need?  The reticulate help at
the GH repo is also good (many old questions you can search).

Good luck,  Dirk

| I started an issue here:
| https://github.com/rstudio/tensorflow.rstudio.com/issues/80
| 
| ```
| library(keras)
| 
| imdb <- dataset_imdb(num_words = 10001)
| train_data <- imdb$train$x
| train_labels <- imdb$train$y
| test_data <- imdb$test$x
| test_labels <- imdb$test$y
| 
| vector2 <- function(sequences, dimension = 10000){
|  results <- array(0, dim = c(length(sequences), dimension))
|  for(i in seq_along(sequences)){
|  results[i,sequences[[i]]] <- 1
|  }
|  results
| }
| 
| X <- vector2(train_data)
| Xt <- vector2(test_data)
| y <- as.numeric(train_labels)
| yt <- as.numeric(test_labels)
| Xv <- X[1:10000, ]
| Xp <- X[-(1:10000), ]
| yv <- y[seq(10000)]
| yp <- y[-seq(10000)]
| 
| model <- keras_model_sequential() %>%
|  layer_dense(16, activation = "relu") %>%
|  layer_dense(16, activation = "relu") %>%
|  layer_dense(1, activation = "sigmoid")
| 
| 
| model %>% compile(optimizer = "rmsprop",
|                  loss = "binary_crossentropy",
|                  metrics = "accuracy")
| 
| 
| history <- model %>% fit( Xp, yp, epochs = 20, batch_size = 512,
|  validation_data = list(Xv, yv)
| )
| ```
| 
| On Wed, 2025-05-14 at 17:20 -0500, Dirk Eddelbuettel wrote:
| > > 
| > > Stephen,
| > > 
| > > Sorry to hear that. I am not sure that hijacking an existing thread
| > > > here is
| > > the best idea -- this is now also deep into reticulate territory, >
| > > will depend
| > > on how you run Python on the box and more.  For what it is worth, >
| > > still works
| > > here
| > > 
| > >     > library("keras")
| > >     > library("tensorflow")
| > >     > search()
| > >      [1] ".GlobalEnv"         "package:tensorflow" >
| > > "package:keras"     
| > >      [4] "ESSR"               "package:stats"      >
| > > "package:graphics"  
| > >      [7] "package:grDevices"  "package:utils"      >
| > > "package:datasets"  
| > >     [10] "package:methods"    "Autoloads"          >
| > > "package:base"      
| > >     >
| > > 
| > > Might be best start over with 'reticulate 101', ie whether you can
| > > > access
| > > Python, test whether you can load the required packages in your >
| > > Python
| > > session and so on.
| > > 
| > > Good luck,  Dirk
| > > 
| 

-- 
dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org


_______________________________________________
R-SIG-Debian mailing list
R-SIG-Debian using r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-debian



More information about the R-SIG-Debian mailing list