Skip to content

Commit

Permalink
Install Tensorflow Metal plugin when on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
fegue committed Jan 29, 2025
1 parent 18a1f0f commit 1bf688f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ install_birdnet <- function(
...,
envname = "r-birdnet",
new_env = identical(envname, "r-birdnet")) {

OS = Sys.info()[["sysname"]]

# Try to use python 3.11. the request is taken as a hint only, and scanning for other versions will still proceed
reticulate::use_python_version(.suggested_python_version(), required = FALSE)

Expand All @@ -48,4 +51,20 @@ install_birdnet <- function(
envname = envname,
...
)

if (OS == "Darwin") {
# Try to install Metal plugin for GPU support
tryCatch(
{
reticulate::py_install("tensorflow-metal", envname = envname)
message("GPU supoort installed successfully!")
},
error = function(e) {
message(
"Failed to install Metal plugin for GPU support. Error: ",
e$message
)
}
)
}
}

0 comments on commit 1bf688f

Please sign in to comment.