@@ -27,11 +27,13 @@ install_keras <- function(
2727 if (is.na(gpu )) {
2828
2929 has_nvidia_gpu <- function () {
30- lspci_listed <- tryCatch(
31- as.logical(length(system(" lspci | grep -i nvidia" , intern = TRUE ))),
32- warning = function (w ) FALSE , # warning emitted by system for non-0 exit status
33- error = function (e ) FALSE
34- )
30+ lspci_listed <- tryCatch({
31+ lspci <- system(" lspci" , intern = TRUE , ignore.stderr = TRUE )
32+ any(grepl(" nvidia" , lspci , ignore.case = TRUE ))
33+ },
34+ warning = function (w ) FALSE ,
35+ error = function (e ) FALSE )
36+
3537 if (lspci_listed )
3638 return (TRUE )
3739
@@ -308,14 +310,12 @@ is_keras_loaded <- function() {
308310has_gpu <- function () {
309311
310312 has_nvidia_gpu <- function () {
311- lspci_listed <- tryCatch(
312- as.logical(length(
313- system(" lspci | grep -i nvidia" , intern = TRUE )
314- )),
315- # warning emitted by system for non-0 exit status
316- warning = function (w ) FALSE ,
317- error = function (e ) FALSE
318- )
313+ lspci_listed <- tryCatch({
314+ lspci <- system(" lspci" , intern = TRUE , ignore.stderr = TRUE )
315+ any(grepl(" nvidia" , lspci , ignore.case = TRUE ))
316+ },
317+ warning = function (w ) FALSE ,
318+ error = function (e ) FALSE )
319319
320320 if (lspci_listed )
321321 return (TRUE )
0 commit comments