Skip to content

Commit b68aa4a

Browse files
authored
Merge pull request #601 from rstudio/fixes-for-numpy2
Fixes for NumPy 2.0
2 parents f4501c7 + d731ed0 commit b68aa4a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- Fixed an issue where GPUs would not be found when running on Windows
44
WSL Linux (reported in rstudio/keras3#1456, fixed in #599)
5+
- Fixes for NumPy 2.0 (#601)
56

67
# tensorflow 2.16.0
78

@@ -10,7 +11,6 @@
1011
- If `install_tensorflow()` detects a GPU on Linux, it will automatically
1112
install the cuda package and configure required symlinks for cudnn and ptxax.
1213

13-
1414
# tensorflow 2.15.0
1515

1616
- `install_tensorflow()` installs TensorFlow v2.15 by default

R/install.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ function(method = c("auto", "virtualenv", "conda"),
198198
as.character(extra_packages)
199199
))
200200

201+
if (isTRUE(extract_numeric_version(version) <= "2.17"))
202+
packages <- c("numpy<2", packages)
201203

202204
if (isTRUE(metal)) repeat {
203205
tf_ver <- extract_numeric_version(tf_package_spec)
@@ -347,7 +349,10 @@ parse_tensorflow_version <- function(version) {
347349

348350

349351
extract_numeric_version <- function(x, strict = FALSE) {
350-
x <- gsub("[^0-9.]+", "", as.character(x), perl = TRUE)
352+
x <- as.character(x)
353+
x <- gsub("-", ".", x, fixed = TRUE)
354+
x <- gsub("[^0-9.]", "", x, perl = TRUE)
355+
x <- gsub("\\.+", ".", x)
351356
x <- sub("^\\.+", "", x)
352357
x <- sub("\\.+$", "", x)
353358
numeric_version(x, strict = strict)

0 commit comments

Comments
 (0)