rstudio / keras3

R Interface to Keras
https://keras3.posit.co/
Other
838 stars 283 forks source link

Installation Issue #1412

Open william-denault opened 8 months ago

william-denault commented 8 months ago

Hello I aam trying to install Tensorflow on a Unix server that use to do some computation. I have followed your instruction below and I get the following error message when I run tensorflow::as_tensor("Hello World")


2024-03-04 06:52:39.913688: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2024-03-04 06:52:39.975193: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2024-03-04 06:52:39.975892: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-03-04 06:52:41.327400: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Error: Valid installation of TensorFlow not found.

Python environments searched for 'tensorflow' package:
 /home/wdenault/.pyenv/versions/3.9.18/bin/python3.9

Python exception encountered:
 Traceback (most recent call last):
  File "/home/wdenault/R/x86_64-pc-linux-gnu-library/4.1/reticulate/python/rpytools/loader.py", line 119, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "/home/wdenault/R/x86_64-pc-linux-gnu-library/4.1/reticulate/python/rpytools/loader.py", line 93, in _run_hook
    module = hook()
  File "/home/wdenault/R/x86_64-pc-linux-gnu-library/4.1/reticulate/python/rpytools/loader.py", line 117, in _hook
    return _find_and_load(name, import_)
  File "/home/wdenault/.virtualenvs/r-tensorflow/lib/python3.9/site-packages/tensorflow/__init__.py", line 52, in <module>
    from ._api.v2 import compat
  File "/home/wdenault/R/x86_64-pc-linux-gnu-library/4.1/reticulate/python/rpytools/loader.py", line 119, in _find_and_load_hook
    return _run_hook(name, _hook

Here is the output of sessionInfo()


sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /software/openblas-0.3.13-el7-x86_64/lib/libopenblas_haswellp-r0.3.13.so

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.12            lattice_0.20-44        here_1.0.1
 [4] png_0.1-8              rprojroot_2.0.4        grid_4.1.0
 [7] lifecycle_1.0.4        jsonlite_1.8.8         magrittr_2.0.3
[10] tfruns_1.5.2           rlang_1.1.3            cli_3.6.2
[13] whisker_0.4.1          Matrix_1.6-5           reticulate_1.35.0.9000
[16] compiler_4.1.0         base64enc_0.1-3        tensorflow_2.15.0.9000

Thank you in advance.

Best regards William

Many installation issues are resolved by running the following in a fresh R session (you can restart R in Rstudio with Ctrl+Shift+F10) :

# install the development version of packages, in case the
# issue is already fixed but not on CRAN yet.
install.packages("remotes")
remotes::install_github(sprintf("rstudio/%s", c("reticulate", "tensorflow", "keras")))
if (is.null(reticulate::virtualenv_starter()))
  reticulate::install_python()
keras3::install_keras()

Test to see if installation was successful.

tensorflow::as_tensor("Hello World")

If the above snippet succeeded and you saw something like tf.Tensor(b'Hello World', shape=(), dtype=string), then :tada:, you've successfully installed Tensorflow.

If the above installation failed, please gather some diagnostic info:

reticulate::py_config()
tensorflow::tf_config()
reticulate::import("tensorflow")
reticulate::py_last_error()
sessionInfo()

Please copy and paste the FULL OUTPUT of running all three snippets, and be sure to enclose the output lines with three backticks (```) for monospace formatting.

t-kalinowski commented 8 months ago

Can you please post the full output from:

reticulate::install_python()
keras3::install_keras()
william-denault commented 8 months ago

Hi @t-kalinowski Thanks for the quick feedback. here the output.


>tensorflow::as_tensor("Hello World")
2024-03-04 12:50:16.002903: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Error: Valid installation of TensorFlow not found.

Python environments searched for 'tensorflow' package:
 /home/wdenault/.pyenv/versions/3.9.18/bin/python3.9

Python exception encountered:
 Traceback (most recent call last):
  File "/home/wdenault/R/x86_64-pc-linux-gnu-library/4.1/reticulate/python/rpytools/loader.py", line 119, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "/home/wdenault/R/x86_64-pc-linux-gnu-library/4.1/reticulate/python/rpytools/loader.py", line 93, in _run_hook
    module = hook()
  File "/home/wdenault/R/x86_64-pc-linux-gnu-library/4.1/reticulate/python/rpytools/loader.py", line 117, in _hook
    return _find_and_load(name, import_)
  File "/home/wdenault/.virtualenvs/r-keras/lib/python3.9/site-packages/tensorflow/__init__.py", line 54, in <module>
    from tensorflow._api.v2 import compat
  File "/home/wdenault/R/x86_64-pc-linux-gnu-library/4.1/reticulate/python/rpytools/loader.py", line 119, in _find_and_load_hook
    return _run_hook(name,
t-kalinowski commented 8 months ago

Hi, Can you please post the output from running these commands:

reticulate::install_python()
keras3::install_keras()

(Not the output from running tensorflow::as_tensor("Hello World"))

william-denault commented 8 months ago

Sorry I did not understood it. Please find the output below,


> reticulate::install_python()
+ /home/wdenault/.local/share/r-reticulate/pyenv/bin/pyenv update
+ /home/wdenault/.local/share/r-reticulate/pyenv/bin/pyenv install --skip-existing 3.9.18
[1] "/home/wdenault/.pyenv/versions/3.9.18/bin/python3.9"
> keras3::install_keras()
Virtual environment 'r-keras' removed.
Using Python: /home/wdenault/.pyenv/versions/3.9.18/bin/python3.9
Creating virtual environment 'r-keras' ...
+ /home/wdenault/.pyenv/versions/3.9.18/bin/python3.9 -m venv /home/wdenault/.virtualenvs/r-keras
Done!
Installing packages: pip, wheel, setuptools
+ /home/wdenault/.virtualenvs/r-keras/bin/python -m pip install --upgrade pip wheel setuptools
Requirement already satisfied: pip in ./.virtualenvs/r-keras/lib/python3.9/site-packages (23.0.1)
Collecting pip
  Using cached pip-24.0-py3-none-any.whl (2.1 MB)
Collecting wheel
  Using cached wheel-0.42.0-py3-none-any.whl (65 kB)
Requirement already satisfied: setuptools in ./.virtualenvs/r-keras/lib/python3.9/site-packages (58.1.0)
Collecting setuptools
  Using cached setuptools-69.1.1-py3-none-any.whl (819 kB)
Installing collected packages: wheel, setuptools, pip
  Attempting uninstall: setuptools
    Found existing installation: setuptools 58.1.0
    Uninstalling setuptools-58.1.0:
      Successfully uninstalled setuptools-58.1.0
  Attempting uninstall: pip
    Found existing installation: pip 23.0.1
    Uninstalling pip-23.0.1:
      Successfully uninstalled pip-23.0.1
Successfully installed pip-24.0 setuptools-69.1.1 wheel-0.42.0
Virtual environment 'r-keras' successfully created.
Using virtual environment 'r-keras' ...
+ /home/wdenault/.virtualenvs/r-keras/bin/python -m pip install --upgrade --no-user scipy pandas Pillow pydot ipython tensorflow_datasets packaging
Collecting scipy
  Using cached scipy-1.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (60 kB)
Collecting pandas
  Using cached pandas-2.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (19 kB)
Collecting Pillow
  Using cached pillow-10.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (9.7 kB)
Collecting pydot
  Using cached pydot-2.0.0-py3-none-any.whl.metadata (9.6 kB)
Collecting ipython
  Using cached ipython-8.18.1-py3-none-any.whl.metadata (6.0 kB)
Collecting tensorflow_datasets
  Using cached tensorflow_datasets-4.9.3-py3-none-any.whl.metadata (9.3 kB)
Collecting packaging
  Using cached packaging-23.2-py3-none-any.whl.metadata (3.2 kB)
Collecting numpy<1.29.0,>=1.22.4 (from scipy)
  Using cached numpy-1.26.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)
Collecting python-dateutil>=2.8.2 (from pandas)
  Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl.metadata (8.4 kB)
Collecting pytz>=2020.1 (from pandas)
  Using cached pytz-2024.1-py2.py3-none-any.whl.metadata (22 kB)
Collecting tzdata>=2022.7 (from pandas)
  Using cached tzdata-2024.1-py2.py3-none-any.whl.metadata (1.4 kB)
Collecting pyparsing>=3 (from pydot)
  Using cached pyparsing-3.1.1-py3-none-any.whl.metadata (5.1 kB)
Collecting decorator (from ipython)
  Using cached decorator-5.1.1-py3-none-any.whl.metadata (4.0 kB)
Collecting jedi>=0.16 (from ipython)
  Using cached jedi-0.19.1-py2.py3-none-any.whl.metadata (22 kB)
Collecting matplotlib-inline (from ipython)
  Using cached matplotlib_inline-0.1.6-py3-none-any.whl.metadata (2.8 kB)
Collecting prompt-toolkit<3.1.0,>=3.0.41 (from ipython)
  Using cached prompt_toolkit-3.0.43-py3-none-any.whl.metadata (6.5 kB)
Collecting pygments>=2.4.0 (from ipython)
  Using cached pygments-2.17.2-py3-none-any.whl.metadata (2.6 kB)
Collecting stack-data (from ipython)
  Using cached stack_data-0.6.3-py3-none-any.whl.metadata (18 kB)
Collecting traitlets>=5 (from ipython)
  Using cached traitlets-5.14.1-py3-none-any.whl.metadata (10 kB)
Collecting typing-extensions (from ipython)
  Using cached typing_extensions-4.10.0-py3-none-any.whl.metadata (3.0 kB)
Collecting exceptiongroup (from ipython)
  Using cached exceptiongroup-1.2.0-py3-none-any.whl.metadata (6.6 kB)
Collecting pexpect>4.3 (from ipython)
  Using cached pexpect-4.9.0-py2.py3-none-any.whl.metadata (2.5 kB)
Collecting absl-py (from tensorflow_datasets)
  Using cached absl_py-2.1.0-py3-none-any.whl.metadata (2.3 kB)
Collecting array-record (from tensorflow_datasets)
  Using cached array_record-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (503 bytes)
Collecting click (from tensorflow_datasets)
  Using cached click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
Collecting dm-tree (from tensorflow_datasets)
  Using cached dm_tree-0.1.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.9 kB)
Collecting etils>=0.9.0 (from etils[enp,epath,etree]>=0.9.0->tensorflow_datasets)
  Using cached etils-1.5.2-py3-none-any.whl.metadata (6.3 kB)
Collecting promise (from tensorflow_datasets)
  Using cached promise-2.3-py3-none-any.whl
Collecting protobuf>=3.20 (from tensorflow_datasets)
  Using cached protobuf-4.25.3-cp37-abi3-manylinux2014_x86_64.whl.metadata (541 bytes)
Collecting psutil (from tensorflow_datasets)
  Using cached psutil-5.9.8-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (21 kB)
Collecting requests>=2.19.0 (from tensorflow_datasets)
  Using cached requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Collecting tensorflow-metadata (from tensorflow_datasets)
  Using cached tensorflow_metadata-1.14.0-py3-none-any.whl.metadata (2.1 kB)
Collecting termcolor (from tensorflow_datasets)
  Using cached termcolor-2.4.0-py3-none-any.whl.metadata (6.1 kB)
Collecting toml (from tensorflow_datasets)
  Using cached toml-0.10.2-py2.py3-none-any.whl.metadata (7.1 kB)
Collecting tqdm (from tensorflow_datasets)
  Using cached tqdm-4.66.2-py3-none-any.whl.metadata (57 kB)
Collecting wrapt (from tensorflow_datasets)
  Using cached wrapt-1.16.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.6 kB)
Collecting fsspec (from etils[enp,epath,etree]>=0.9.0->tensorflow_datasets)
  Using cached fsspec-2024.2.0-py3-none-any.whl.metadata (6.8 kB)
Collecting importlib_resources (from etils[enp,epath,etree]>=0.9.0->tensorflow_datasets)
  Using cached importlib_resources-6.1.2-py3-none-any.whl.metadata (3.9 kB)
Collecting zipp (from etils[enp,epath,etree]>=0.9.0->tensorflow_datasets)
  Using cached zipp-3.17.0-py3-none-any.whl.metadata (3.7 kB)
Collecting parso<0.9.0,>=0.8.3 (from jedi>=0.16->ipython)
  Using cached parso-0.8.3-py2.py3-none-any.whl.metadata (7.5 kB)
Collecting ptyprocess>=0.5 (from pexpect>4.3->ipython)
  Using cached ptyprocess-0.7.0-py2.py3-none-any.whl.metadata (1.3 kB)
Collecting wcwidth (from prompt-toolkit<3.1.0,>=3.0.41->ipython)
  Using cached wcwidth-0.2.13-py2.py3-none-any.whl.metadata (14 kB)
Collecting six>=1.5 (from python-dateutil>=2.8.2->pandas)
  Using cached six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
Collecting charset-normalizer<4,>=2 (from requests>=2.19.0->tensorflow_datasets)
  Using cached charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (33 kB)
Collecting idna<4,>=2.5 (from requests>=2.19.0->tensorflow_datasets)
  Using cached idna-3.6-py3-none-any.whl.metadata (9.9 kB)
Collecting urllib3<3,>=1.21.1 (from requests>=2.19.0->tensorflow_datasets)
  Using cached urllib3-2.2.1-py3-none-any.whl.metadata (6.4 kB)
Collecting certifi>=2017.4.17 (from requests>=2.19.0->tensorflow_datasets)
  Using cached certifi-2024.2.2-py3-none-any.whl.metadata (2.2 kB)
Collecting executing>=1.2.0 (from stack-data->ipython)
  Using cached executing-2.0.1-py2.py3-none-any.whl.metadata (9.0 kB)
Collecting asttokens>=2.1.0 (from stack-data->ipython)
  Using cached asttokens-2.4.1-py2.py3-none-any.whl.metadata (5.2 kB)
Collecting pure-eval (from stack-data->ipython)
  Using cached pure_eval-0.2.2-py3-none-any.whl.metadata (6.2 kB)
Collecting absl-py (from tensorflow_datasets)
  Using cached absl_py-1.4.0-py3-none-any.whl.metadata (2.3 kB)
Collecting googleapis-common-protos<2,>=1.52.0 (from tensorflow-metadata->tensorflow_datasets)
  Using cached googleapis_common_protos-1.62.0-py2.py3-none-any.whl.metadata (1.5 kB)
Collecting protobuf>=3.20 (from tensorflow_datasets)
  Using cached protobuf-3.20.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl.metadata (679 bytes)
Using cached scipy-1.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.5 MB)
Using cached pandas-2.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.0 MB)
Using cached pillow-10.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB)
Using cached pydot-2.0.0-py3-none-any.whl (22 kB)
Using cached ipython-8.18.1-py3-none-any.whl (808 kB)
Using cached tensorflow_datasets-4.9.3-py3-none-any.whl (5.0 MB)
Using cached packaging-23.2-py3-none-any.whl (53 kB)
Using cached etils-1.5.2-py3-none-any.whl (140 kB)
Using cached jedi-0.19.1-py2.py3-none-any.whl (1.6 MB)
Using cached numpy-1.26.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB)
Using cached pexpect-4.9.0-py2.py3-none-any.whl (63 kB)
Using cached prompt_toolkit-3.0.43-py3-none-any.whl (386 kB)
Using cached pygments-2.17.2-py3-none-any.whl (1.2 MB)
Using cached pyparsing-3.1.1-py3-none-any.whl (103 kB)
Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
Using cached pytz-2024.1-py2.py3-none-any.whl (505 kB)
Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Using cached traitlets-5.14.1-py3-none-any.whl (85 kB)
Using cached tzdata-2024.1-py2.py3-none-any.whl (345 kB)
Using cached array_record-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB)
Using cached click-8.1.7-py3-none-any.whl (97 kB)
Using cached decorator-5.1.1-py3-none-any.whl (9.1 kB)
Using cached dm_tree-0.1.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (153 kB)
Using cached exceptiongroup-1.2.0-py3-none-any.whl (16 kB)
Using cached matplotlib_inline-0.1.6-py3-none-any.whl (9.4 kB)
Using cached psutil-5.9.8-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (288 kB)
Using cached stack_data-0.6.3-py3-none-any.whl (24 kB)
Using cached tensorflow_metadata-1.14.0-py3-none-any.whl (28 kB)
Using cached absl_py-1.4.0-py3-none-any.whl (126 kB)
Using cached protobuf-3.20.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.0 MB)
Using cached termcolor-2.4.0-py3-none-any.whl (7.7 kB)
Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Using cached tqdm-4.66.2-py3-none-any.whl (78 kB)
Using cached typing_extensions-4.10.0-py3-none-any.whl (33 kB)
Using cached wrapt-1.16.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (80 kB)
Using cached asttokens-2.4.1-py2.py3-none-any.whl (27 kB)
Using cached certifi-2024.2.2-py3-none-any.whl (163 kB)
Using cached charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142 kB)
Using cached executing-2.0.1-py2.py3-none-any.whl (24 kB)
Using cached googleapis_common_protos-1.62.0-py2.py3-none-any.whl (228 kB)
Using cached idna-3.6-py3-none-any.whl (61 kB)
Using cached parso-0.8.3-py2.py3-none-any.whl (100 kB)
Using cached ptyprocess-0.7.0-py2.py3-none-any.whl (13 kB)
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Using cached urllib3-2.2.1-py3-none-any.whl (121 kB)
Using cached fsspec-2024.2.0-py3-none-any.whl (170 kB)
Using cached importlib_resources-6.1.2-py3-none-any.whl (34 kB)
Using cached zipp-3.17.0-py3-none-any.whl (7.4 kB)
Using cached pure_eval-0.2.2-py3-none-any.whl (11 kB)
Using cached wcwidth-0.2.13-py2.py3-none-any.whl (34 kB)
Installing collected packages: wcwidth, pytz, pure-eval, ptyprocess, dm-tree, zipp, wrapt, urllib3, tzdata, typing-extensions, traitlets, tqdm, toml, termcolor, six, pyparsing, pygments, psutil, protobuf, prompt-toolkit, Pillow, pexpect, parso, packaging, numpy, idna, fsspec, executing, exceptiongroup, etils, decorator, click, charset-normalizer, certifi, absl-py, scipy, requests, python-dateutil, pydot, promise, matplotlib-inline, jedi, importlib_resources, googleapis-common-protos, asttokens, tensorflow-metadata, stack-data, pandas, ipython, array-record, tensorflow_datasets
Successfully installed Pillow-10.2.0 absl-py-1.4.0 array-record-0.5.0 asttokens-2.4.1 certifi-2024.2.2 charset-normalizer-3.3.2 click-8.1.7 decorator-5.1.1 dm-tree-0.1.8 etils-1.5.2 exceptiongroup-1.2.0 executing-2.0.1 fsspec-2024.2.0 googleapis-common-protos-1.62.0 idna-3.6 importlib_resources-6.1.2 ipython-8.18.1 jedi-0.19.1 matplotlib-inline-0.1.6 numpy-1.26.4 packaging-23.2 pandas-2.2.1 parso-0.8.3 pexpect-4.9.0 promise-2.3 prompt-toolkit-3.0.43 protobuf-3.20.3 psutil-5.9.8 ptyprocess-0.7.0 pure-eval-0.2.2 pydot-2.0.0 pygments-2.17.2 pyparsing-3.1.1 python-dateutil-2.9.0.post0 pytz-2024.1 requests-2.31.0 scipy-1.12.0 six-1.16.0 stack-data-0.6.3 tensorflow-metadata-1.14.0 tensorflow_datasets-4.9.3 termcolor-2.4.0 toml-0.10.2 tqdm-4.66.2 traitlets-5.14.1 typing-extensions-4.10.0 tzdata-2024.1 urllib3-2.2.1 wcwidth-0.2.13 wrapt-1.16.0 zipp-3.17.0
Using virtual environment 'r-keras' ...
+ /home/wdenault/.virtualenvs/r-keras/bin/python -m pip install --upgrade --no-user tensorflow-cpu 'jax[cpu]'
Collecting tensorflow-cpu
  Using cached tensorflow_cpu-2.15.0.post1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.2 kB)
Collecting jax[cpu]
  Using cached jax-0.4.25-py3-none-any.whl.metadata (24 kB)
Requirement already satisfied: absl-py>=1.0.0 in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from tensorflow-cpu) (1.4.0)
Collecting astunparse>=1.6.0 (from tensorflow-cpu)
  Using cached astunparse-1.6.3-py2.py3-none-any.whl.metadata (4.4 kB)
Collecting flatbuffers>=23.5.26 (from tensorflow-cpu)
  Using cached flatbuffers-23.5.26-py2.py3-none-any.whl.metadata (850 bytes)
Collecting gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 (from tensorflow-cpu)
  Using cached gast-0.5.4-py3-none-any.whl.metadata (1.3 kB)
Collecting google-pasta>=0.1.1 (from tensorflow-cpu)
  Using cached google_pasta-0.2.0-py3-none-any.whl.metadata (814 bytes)
Collecting h5py>=2.9.0 (from tensorflow-cpu)
  Using cached h5py-3.10.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.5 kB)
Collecting libclang>=13.0.0 (from tensorflow-cpu)
  Using cached libclang-16.0.6-py2.py3-none-manylinux2010_x86_64.whl.metadata (5.2 kB)
Collecting ml-dtypes~=0.2.0 (from tensorflow-cpu)
  Using cached ml_dtypes-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (20 kB)
Requirement already satisfied: numpy<2.0.0,>=1.23.5 in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from tensorflow-cpu) (1.26.4)
Collecting opt-einsum>=2.3.2 (from tensorflow-cpu)
  Using cached opt_einsum-3.3.0-py3-none-any.whl.metadata (6.5 kB)
Requirement already satisfied: packaging in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from tensorflow-cpu) (23.2)
Requirement already satisfied: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3 in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from tensorflow-cpu) (3.20.3)
Requirement already satisfied: setuptools in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from tensorflow-cpu) (69.1.1)
Requirement already satisfied: six>=1.12.0 in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from tensorflow-cpu) (1.16.0)
Requirement already satisfied: termcolor>=1.1.0 in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from tensorflow-cpu) (2.4.0)
Requirement already satisfied: typing-extensions>=3.6.6 in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from tensorflow-cpu) (4.10.0)
Collecting wrapt<1.15,>=1.11.0 (from tensorflow-cpu)
  Using cached wrapt-1.14.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.7 kB)
Collecting tensorflow-io-gcs-filesystem>=0.23.1 (from tensorflow-cpu)
  Using cached tensorflow_io_gcs_filesystem-0.36.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (14 kB)
Collecting grpcio<2.0,>=1.24.3 (from tensorflow-cpu)
  Using cached grpcio-1.62.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.0 kB)
Collecting tensorboard<2.16,>=2.15 (from tensorflow-cpu)
  Using cached tensorboard-2.15.2-py3-none-any.whl.metadata (1.7 kB)
Collecting tensorflow-estimator<2.16,>=2.15.0 (from tensorflow-cpu)
  Using cached tensorflow_estimator-2.15.0-py2.py3-none-any.whl.metadata (1.3 kB)
Collecting keras<2.16,>=2.15.0 (from tensorflow-cpu)
  Using cached keras-2.15.0-py3-none-any.whl.metadata (2.4 kB)
Requirement already satisfied: scipy>=1.9 in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from jax[cpu]) (1.12.0)
Collecting importlib-metadata>=4.6 (from jax[cpu])
  Using cached importlib_metadata-7.0.1-py3-none-any.whl.metadata (4.9 kB)
Collecting jaxlib==0.4.25 (from jax[cpu])
  Using cached jaxlib-0.4.25-cp39-cp39-manylinux2014_x86_64.whl.metadata (2.1 kB)
Requirement already satisfied: wheel<1.0,>=0.23.0 in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from astunparse>=1.6.0->tensorflow-cpu) (0.42.0)
Requirement already satisfied: zipp>=0.5 in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from importlib-metadata>=4.6->jax[cpu]) (3.17.0)
Collecting google-auth<3,>=1.6.3 (from tensorboard<2.16,>=2.15->tensorflow-cpu)
  Using cached google_auth-2.28.1-py2.py3-none-any.whl.metadata (4.7 kB)
Collecting google-auth-oauthlib<2,>=0.5 (from tensorboard<2.16,>=2.15->tensorflow-cpu)
  Using cached google_auth_oauthlib-1.2.0-py2.py3-none-any.whl.metadata (2.7 kB)
Collecting markdown>=2.6.8 (from tensorboard<2.16,>=2.15->tensorflow-cpu)
  Using cached Markdown-3.5.2-py3-none-any.whl.metadata (7.0 kB)
Requirement already satisfied: requests<3,>=2.21.0 in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from tensorboard<2.16,>=2.15->tensorflow-cpu) (2.31.0)
Collecting tensorboard-data-server<0.8.0,>=0.7.0 (from tensorboard<2.16,>=2.15->tensorflow-cpu)
  Using cached tensorboard_data_server-0.7.2-py3-none-any.whl.metadata (1.1 kB)
Collecting werkzeug>=1.0.1 (from tensorboard<2.16,>=2.15->tensorflow-cpu)
  Using cached werkzeug-3.0.1-py3-none-any.whl.metadata (4.1 kB)
Collecting cachetools<6.0,>=2.0.0 (from google-auth<3,>=1.6.3->tensorboard<2.16,>=2.15->tensorflow-cpu)
  Using cached cachetools-5.3.3-py3-none-any.whl.metadata (5.3 kB)
Collecting pyasn1-modules>=0.2.1 (from google-auth<3,>=1.6.3->tensorboard<2.16,>=2.15->tensorflow-cpu)
  Using cached pyasn1_modules-0.3.0-py2.py3-none-any.whl.metadata (3.6 kB)
Collecting rsa<5,>=3.1.4 (from google-auth<3,>=1.6.3->tensorboard<2.16,>=2.15->tensorflow-cpu)
  Using cached rsa-4.9-py3-none-any.whl.metadata (4.2 kB)
Collecting requests-oauthlib>=0.7.0 (from google-auth-oauthlib<2,>=0.5->tensorboard<2.16,>=2.15->tensorflow-cpu)
  Using cached requests_oauthlib-1.3.1-py2.py3-none-any.whl.metadata (10 kB)
Requirement already satisfied: charset-normalizer<4,>=2 in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from requests<3,>=2.21.0->tensorboard<2.16,>=2.15->tensorflow-cpu) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from requests<3,>=2.21.0->tensorboard<2.16,>=2.15->tensorflow-cpu) (3.6)
Requirement already satisfied: urllib3<3,>=1.21.1 in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from requests<3,>=2.21.0->tensorboard<2.16,>=2.15->tensorflow-cpu) (2.2.1)
Requirement already satisfied: certifi>=2017.4.17 in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from requests<3,>=2.21.0->tensorboard<2.16,>=2.15->tensorflow-cpu) (2024.2.2)
Collecting MarkupSafe>=2.1.1 (from werkzeug>=1.0.1->tensorboard<2.16,>=2.15->tensorflow-cpu)
  Using cached MarkupSafe-2.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.0 kB)
Collecting pyasn1<0.6.0,>=0.4.6 (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard<2.16,>=2.15->tensorflow-cpu)
  Using cached pyasn1-0.5.1-py2.py3-none-any.whl.metadata (8.6 kB)
Collecting oauthlib>=3.0.0 (from requests-oauthlib>=0.7.0->google-auth-oauthlib<2,>=0.5->tensorboard<2.16,>=2.15->tensorflow-cpu)
  Using cached oauthlib-3.2.2-py3-none-any.whl.metadata (7.5 kB)
Using cached tensorflow_cpu-2.15.0.post1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (207.2 MB)
Using cached jaxlib-0.4.25-cp39-cp39-manylinux2014_x86_64.whl (79.2 MB)
Using cached astunparse-1.6.3-py2.py3-none-any.whl (12 kB)
Using cached flatbuffers-23.5.26-py2.py3-none-any.whl (26 kB)
Using cached gast-0.5.4-py3-none-any.whl (19 kB)
Using cached google_pasta-0.2.0-py3-none-any.whl (57 kB)
Using cached grpcio-1.62.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.6 MB)
Using cached h5py-3.10.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.8 MB)
Using cached importlib_metadata-7.0.1-py3-none-any.whl (23 kB)
Using cached keras-2.15.0-py3-none-any.whl (1.7 MB)
Using cached libclang-16.0.6-py2.py3-none-manylinux2010_x86_64.whl (22.9 MB)
Using cached ml_dtypes-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB)
Using cached opt_einsum-3.3.0-py3-none-any.whl (65 kB)
Using cached tensorboard-2.15.2-py3-none-any.whl (5.5 MB)
Using cached tensorflow_estimator-2.15.0-py2.py3-none-any.whl (441 kB)
Using cached tensorflow_io_gcs_filesystem-0.36.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.1 MB)
Using cached wrapt-1.14.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (77 kB)
Using cached jax-0.4.25-py3-none-any.whl (1.8 MB)
Using cached google_auth-2.28.1-py2.py3-none-any.whl (186 kB)
Using cached google_auth_oauthlib-1.2.0-py2.py3-none-any.whl (24 kB)
Using cached Markdown-3.5.2-py3-none-any.whl (103 kB)
Using cached tensorboard_data_server-0.7.2-py3-none-any.whl (2.4 kB)
Using cached werkzeug-3.0.1-py3-none-any.whl (226 kB)
Using cached cachetools-5.3.3-py3-none-any.whl (9.3 kB)
Using cached MarkupSafe-2.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Using cached pyasn1_modules-0.3.0-py2.py3-none-any.whl (181 kB)
Using cached requests_oauthlib-1.3.1-py2.py3-none-any.whl (23 kB)
Using cached rsa-4.9-py3-none-any.whl (34 kB)
Using cached oauthlib-3.2.2-py3-none-any.whl (151 kB)
Using cached pyasn1-0.5.1-py2.py3-none-any.whl (84 kB)
Installing collected packages: libclang, flatbuffers, wrapt, tensorflow-io-gcs-filesystem, tensorflow-estimator, tensorboard-data-server, pyasn1, opt-einsum, oauthlib, ml-dtypes, MarkupSafe, keras, importlib-metadata, h5py, grpcio, google-pasta, gast, cachetools, astunparse, werkzeug, rsa, requests-oauthlib, pyasn1-modules, markdown, jaxlib, jax, google-auth, google-auth-oauthlib, tensorboard, tensorflow-cpu
  Attempting uninstall: wrapt
    Found existing installation: wrapt 1.16.0
    Uninstalling wrapt-1.16.0:
      Successfully uninstalled wrapt-1.16.0
Successfully installed MarkupSafe-2.1.5 astunparse-1.6.3 cachetools-5.3.3 flatbuffers-23.5.26 gast-0.5.4 google-auth-2.28.1 google-auth-oauthlib-1.2.0 google-pasta-0.2.0 grpcio-1.62.0 h5py-3.10.0 importlib-metadata-7.0.1 jax-0.4.25 jaxlib-0.4.25 keras-2.15.0 libclang-16.0.6 markdown-3.5.2 ml-dtypes-0.2.0 oauthlib-3.2.2 opt-einsum-3.3.0 pyasn1-0.5.1 pyasn1-modules-0.3.0 requests-oauthlib-1.3.1 rsa-4.9 tensorboard-2.15.2 tensorboard-data-server-0.7.2 tensorflow-cpu-2.15.0.post1 tensorflow-estimator-2.15.0 tensorflow-io-gcs-filesystem-0.36.0 werkzeug-3.0.1 wrapt-1.14.1
Using virtual environment 'r-keras' ...
+ /home/wdenault/.virtualenvs/r-keras/bin/python -m pip install --upgrade --no-user 'keras==3.0.*'
Collecting keras==3.0.*
  Using cached keras-3.0.5-py3-none-any.whl.metadata (4.8 kB)
Requirement already satisfied: absl-py in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from keras==3.0.*) (1.4.0)
Requirement already satisfied: numpy in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from keras==3.0.*) (1.26.4)
Collecting rich (from keras==3.0.*)
  Using cached rich-13.7.1-py3-none-any.whl.metadata (18 kB)
Collecting namex (from keras==3.0.*)
  Using cached namex-0.0.7-py3-none-any.whl.metadata (246 bytes)
Requirement already satisfied: h5py in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from keras==3.0.*) (3.10.0)
Requirement already satisfied: dm-tree in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from keras==3.0.*) (0.1.8)
Requirement already satisfied: ml-dtypes in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from keras==3.0.*) (0.2.0)
Collecting markdown-it-py>=2.2.0 (from rich->keras==3.0.*)
  Using cached markdown_it_py-3.0.0-py3-none-any.whl.metadata (6.9 kB)
Requirement already satisfied: pygments<3.0.0,>=2.13.0 in ./.virtualenvs/r-keras/lib/python3.9/site-packages (from rich->keras==3.0.*) (2.17.2)
Collecting mdurl~=0.1 (from markdown-it-py>=2.2.0->rich->keras==3.0.*)
  Using cached mdurl-0.1.2-py3-none-any.whl.metadata (1.6 kB)
Using cached keras-3.0.5-py3-none-any.whl (1.0 MB)
Using cached namex-0.0.7-py3-none-any.whl (5.8 kB)
Using cached rich-13.7.1-py3-none-any.whl (240 kB)
Using cached markdown_it_py-3.0.0-py3-none-any.whl (87 kB)
Using cached mdurl-0.1.2-py3-none-any.whl (10.0 kB)
Installing collected packages: namex, mdurl, markdown-it-py, rich, keras
  Attempting uninstall: keras
    Found existing installation: keras 2.15.0
    Uninstalling keras-2.15.0:
      Successfully uninstalled keras-2.15.0
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow-cpu 2.15.0.post1 requires keras<2.16,>=2.15.0, but you have keras 3.0.5 which is incompatible.
Successfully installed keras-3.0.5 markdown-it-py-3.0.0 mdurl-0.1.2 namex-0.0.7 rich-13.7.1
Finished installing Keras!
t-kalinowski commented 8 months ago

Thanks, it looks like installation succeeded.

I think the issue is:

You can explicitely choose a venv:

library(keras3)
library(tensorflow)

use_virtualenv("r-keras")
william-denault commented 8 months ago

Ok but it seems that keras 3 has a different way to be written than keras do you have any doc about it

For example this would work in keras but not in keras 3


param_nnet =keras_model_sequential() %>%
  layer_dense(units = 64,
              activation = 'relu',
              input_shape = c(1)) %>%
  layer_dense(units = 64,
              activation = 'relu' ) %>% 
  layer_dense(units = 64,
              activation = 'relu' ) %>%
  layer_dense(units = 64,
              activation = 'relu' ) %>%
  layer_dense(units = 10,
              activation = 'softmax')

with keras 3 I got the following output


2024-03-07 14:55:41.383476: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Error: ImportError: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips  26 Jan 2017'. See: https://github.com/urllib3/urllib3/issues/2168
Run `reticulate::py_last_error()` for details.

I have tried to update python ssl manual without success

t-kalinowski commented 8 months ago

The ssl error is likely due to the fact that you're on a relatively old OS (CentOS 7), but trying to use a relatively new Python. I think usually pyenv (what powers reticulate::install_python())takes care of issues like this, or reports useful error messages for how to resolve. A good first step would be to run

reticulate::install_python(force = TRUE)

And read the output carefully. See if there is anything that looks like an error message related to SSL.

This link might also be helpful for troubleshooting. https://github.com/pyenv/pyenv/wiki/Common-build-problems#error-the-python-ssl-extension-was-not-compiled-missing-the-openssl-lib

Bottom line, you don't have a valid Python installation that's currently not EOL'd.