File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,18 @@ keras <- NULL
7272 # the tensorflow R package calls `py_require()` to ensure GPU is usable on Linux
7373 # use_backend() includes py_require(action = "remove") calls to undo
7474 # what tensorflow:::.onLoad() did. Keep them in sync!
75- use_backend(Sys.getenv(" KERAS_BACKEND" , " tensorflow" ))
75+ backend <- Sys.getenv(" KERAS_BACKEND" , " tensorflow" )
76+ gpu <- NA
77+ if (endsWith(backend , " -cpu" )) {
78+ gpu <- FALSE
79+ backend <- sub(" -cpu$" , " " , backend )
80+ Sys.setenv(" KERAS_BACKEND" = backend )
81+ } else if (endsWith(backend , " -gpu" )) {
82+ gpu <- TRUE
83+ backend <- sub(" -gpu$" , " " , backend )
84+ Sys.setenv(" KERAS_BACKEND" = backend )
85+ }
86+ use_backend(backend , gpu )
7687
7788 # delay load keras
7889 try(keras <<- import(" keras" , delay_load = list (
You can’t perform that action at this time.
0 commit comments