-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
System information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 20.04
- TensorFlow.js converter installed with pip in a conda env
- TensorFlow.js version:
In Python 3.6.8
tensorflowjs 3.18.0
Dependency versions:
keras 2.6.0
tensorflow 2.6.2
pip 21.3.1In Python 3.8
tensorflowjs 4.11.0
# error, see below
pip 23.2.1- CUDA/cuDNN version: [Unsure: probably a part of the installation that is taken for granted in the docs? I installed the required dependencies in my other env for the latest Python TF, but for tensorflowjs & tf-nightly-cpu-2.0-preview, where do I find this?]
Describe the problem
I'm hoping to find the simplest, and clearest way to install the converter to get students to convert small models from Python to JS, which may prove difficult at this point.
I tried with conda for the base python, followed by pip (hoping I wouldn't have to use pyenv, which would add more install complexity, especially for non MacOS users). Strangely, things seem to be working with python 3.8, but not with 3.6.8.
Provide the exact sequence of commands / steps that you executed before running into the problem
conda create -n tfjs-convert python=3.6.8
conda activate tfjs-convert
which pip # correctly points to env pip
pip install tf-nightly-cpu-2.0-preview
pip install tensorflowjsSee below the error that I get.
When I do this, however, things seem to work out of the box, but that's not in the docs:
conda create -n tfjs-convert python=3.8
conda activate tfjs-convert
which pip # correctly points to env pip
pip install tensorflowjs # no tf install prior to thisI'm assuming (hoping) that in principle using a conda env with only python and pip installed should be equivalent to using venv with the same. Could someone confirm that, or confirm that the steps in the docs work on an Ubuntu machine?
Is there any chance you could either:
- guarantee that the steps in the docs just work on your end;
- see if there's a way for a conda (for python) followed by pip commands would work as well; or even
- provide a Docker container that people can just run and that works out of the box?
Also, as you can see, my attempt is with a .keras model, which again worked, but isn't present in the readme...?
The functionalities are very nice and promising, and as said I managed to convert a small DCGAN, but the recurrent issues around install, broken libraries links (also in TF updates), are a real barrier of entry (it seems simpler to me now to write a Flask app all in Python rather than guaranteeing the conversion will work)?
I feel like there's probably a lot of places where I made mistakes here, so I understand if it's a bit difficult to untangle all this, but thanks in advance for any pointers!
Any other info / logs
Error with Python 3.6.8
[In hindsight, probably because the .keras format is not supported yet in this version?]
tensorflowjs_converter --input_format=keras_saved_model ../python/models/dcgan_mnist/e100_generator_mnist.keras other_dcgan_test
2023-10-11 10:57:05.119439: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2023-10-11 10:57:08.211946: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2023-10-11 10:57:08.212087: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcublas.so.11'; dlerror: libcublas.so.11: cannot open shared object file: No such file or directory
2023-10-11 10:57:08.212201: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcublasLt.so.11'; dlerror: libcublasLt.so.11: cannot open shared object file: No such file or directory
2023-10-11 10:57:08.212357: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcufft.so.10'; dlerror: libcufft.so.10: cannot open shared object file: No such file or directory
2023-10-11 10:57:08.212469: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcurand.so.10'; dlerror: libcurand.so.10: cannot open shared object file: No such file or directory
2023-10-11 10:57:08.212602: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcusolver.so.11'; dlerror: libcusolver.so.11: cannot open shared object file: No such file or directory
2023-10-11 10:57:08.212730: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcusparse.so.11'; dlerror: libcusparse.so.11: cannot open shared object file: No such file or directory
2023-10-11 10:57:08.213008: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1835] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
Traceback (most recent call last):
File "/home/jcw/anaconda3/envs/tfjs-convert/bin/tensorflowjs_converter", line 8, in <module>
sys.exit(pip_main())
File "/home/jcw/anaconda3/envs/tfjs-convert/lib/python3.6/site-packages/tensorflowjs/converters/converter.py", line 813, in pip_main
main([' '.join(sys.argv[1:])])
File "/home/jcw/anaconda3/envs/tfjs-convert/lib/python3.6/site-packages/tensorflowjs/converters/converter.py", line 817, in main
convert(argv[0].split(' '))
File "/home/jcw/anaconda3/envs/tfjs-convert/lib/python3.6/site-packages/tensorflowjs/converters/converter.py", line 804, in convert
weight_shard_size_bytes, metadata_map)
File "/home/jcw/anaconda3/envs/tfjs-convert/lib/python3.6/site-packages/tensorflowjs/converters/converter.py", line 520, in _dispatch_converter
metadata=metadata_map)
File "/home/jcw/anaconda3/envs/tfjs-convert/lib/python3.6/site-packages/tensorflowjs/converters/converter.py", line 190, in dispatch_keras_saved_model_to_tensorflowjs_conversion
model = tf.keras.models.load_model(keras_saved_model_path)
File "/home/jcw/anaconda3/envs/tfjs-convert/lib/python3.6/site-packages/keras/saving/save.py", line 205, in load_model
return saved_model_load.load(filepath, compile, options)
File "/home/jcw/anaconda3/envs/tfjs-convert/lib/python3.6/site-packages/keras/saving/saved_model/load.py", line 108, in load
meta_graph_def = tf.__internal__.saved_model.parse_saved_model(path).meta_graphs[0]
File "/home/jcw/anaconda3/envs/tfjs-convert/lib/python3.6/site-packages/tensorflow/python/saved_model/loader_impl.py", line 121, in parse_saved_model
constants.SAVED_MODEL_FILENAME_PB))
OSError: SavedModel file does not exist at: ../DMLAP/python/models/dcgan_mnist/e100_generator_mnist.keras/{saved_model.pbtxt|saved_model.pb}Seems to work with Python 3.8?
tfjs tensorflowjs_converter --input_format=keras_saved_model ../python/models/dcgan_mnist/e100_generator_mnist.keras other_dcgan_test
2023-10-11 11:14:19.008061: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
WARNING:root:TensorFlow Decision Forests 1.5.0 is compatible with the following TensorFlow Versions: ['2.13.0']. However, TensorFlow 2.13.1 was detected. This can cause issues with the TF API and symbols in the custom C++ ops. See the TF and TF-DF compatibility table at https://github.com/tensorflow/decision-forests/blob/main/documentation/known_issues.md#compatibility-table.
2023-10-11 11:14:22.209841: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1960] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
WARNING:tensorflow:From /home/jcw/.local/lib/python3.8/site-packages/keras/src/layers/normalization/batch_normalization.py:883: _colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
WARNING:tensorflow:From /home/jcw/.local/lib/python3.8/site-packages/keras/src/layers/normalization/batch_normalization.py:883: _colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
/home/jcw/.local/lib/python3.8/site-packages/keras/src/engine/training.py:3000: UserWarning: You are saving your model as an HDF5 file via `model.save()`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')`.
saving_api.save_model(
2023-10-11 11:14:23.480776: W tensorflow/c/c_api.cc:304] Operation '{name:'batch_normalization_2/moving_mean/Assign' id:213 op device:{requested: '', assigned: ''} def:{{{node batch_normalization_2/moving_mean/Assign}} = AssignVariableOp[_has_manual_control_dependencies=true, dtype=DT_FLOAT, validate_shape=false](batch_normalization_2/moving_mean, batch_normalization_2/moving_mean/Initializer/zeros)}}' was changed by setting attribute after it was run by a session. This mutation will have no effect, and will trigger an error in the future. Either don't modify nodes after running them or create a new session.tfjs version error in Python 3.8
tensorflowjs 4.11.0
Dependency versions:
Traceback (most recent call last):
File "/home/jcw/anaconda3/envs/dmlap-convert/bin/tensorflowjs_converter", line 8, in <module>
sys.exit(pip_main())
File "/home/jcw/anaconda3/envs/dmlap-convert/lib/python3.8/site-packages/tensorflowjs/converters/converter.py", line 958, in pip_main
main([' '.join(sys.argv[1:])])
File "/home/jcw/anaconda3/envs/dmlap-convert/lib/python3.8/site-packages/tensorflowjs/converters/converter.py", line 962, in main
convert(argv[0].split(' '))
File "/home/jcw/anaconda3/envs/dmlap-convert/lib/python3.8/site-packages/tensorflowjs/converters/converter.py", line 888, in convert
print(' keras %s' % tf.keras.__version__)
File "/home/jcw/anaconda3/envs/dmlap-convert/lib/python3.8/site-packages/tensorflow/python/util/lazy_loader.py", line 59, in __getattr__
return getattr(module, item)
AttributeError: module 'keras.api._v2.keras' has no attribute '__version__'Note
In none of the environments I create (and even with conda install pip to upgrade) does the command pip install tensorflowjs[wizard] works (I'm not sure if the brackets are an option of an older, or newer, version of pip). pip install tensorflowjs works, of course, and the wizard ships with it (although I get all sorts of errors and warnings).