J'ai une erreur dans l'importation de tf-sentencepiece sur colab.
J'utilise tensorflow version 2.0, et j'ai installé tf-sentencepiece.
!pip install --upgrade pip
!pip install tensorflow==2.0.0-rc1
!pip3 install --quiet tensorflow-hub
!pip3 install --quiet seaborn
!pip3 install sentencepiece
!pip3 install tf_sentencepiece
Mais lorsque j'essaie d'importer tf-sentencepice, l'erreur suivante se produit
/usr/local/lib/python3.6/dist-packages/tf_sentencepiece/sentencepiece_processor_ops.py:43: UserWarning: No so file is found for [2.0.0-rc1] from [3.6/dist-packages/tf_sentencepiece/_sentencepiece_processor_ops.so.1.11.0, 3.6/dist-packages/tf_sentencepiece/_sentencepiece_processor_ops.so.2.0.0-beta1, 3.6/dist-packages/tf_sentencepiece/_sentencepiece_processor_ops.so.1.7.0, 3.6/dist-packages/tf_sentencepiece/_sentencepiece_processor_ops.so.1.14.0, 3.6/dist-packages/tf_sentencepiece/_sentencepiece_processor_ops.so.1.9.0, 3.6/dist-packages/tf_sentencepiece/_sentencepiece_processor_ops.so.1.8.0, 3.6/dist-packages/tf_sentencepiece/_sentencepiece_processor_ops.so.1.10.0, 3.6/dist-packages/tf_sentencepiece/_sentencepiece_processor_ops.so.1.13.1]
(tf.__version__, ', '.join(versions)))
/usr/local/lib/python3.6/dist-packages/tf_sentencepiece/sentencepiece_processor_ops.py:44: UserWarning: use the latest version 3.6/dist-packages/tf_sentencepiece/_sentencepiece_processor_ops.so.2.0.0-beta1
warnings.warn('use the latest version %s' % (latest))
---------------------------------------------------------------------------
NotFoundError Traceback (most recent call last)
<ipython-input-17-cadbc83432ee> in <module>()
9 from tensorflow.python.framework.ops import disable_eager_execution
10 import sentencepiece
---> 11 import tf_sentencepiece
12
13 #disable_eager_execution()
2 frames
/usr/local/lib/python3.6/dist-packages/tf_sentencepiece/__init__.py in <module>()
3 from __future__ import print_function
4
----> 5 from tf_sentencepiece.sentencepiece_processor_ops import *
/usr/local/lib/python3.6/dist-packages/tf_sentencepiece/sentencepiece_processor_ops.py in <module>()
45 so_file = so_base + '.' + latest
46
---> 47 _gen_sentencepiece_processor_op = tf.load_op_library(so_file)
48
49
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/load_library.py in load_op_library(library_filename)
59 RuntimeError: when unable to load the library or get the python wrappers.
60 """
---> 61 lib_handle = py_tf.TF_LoadLibrary(library_filename)
62
63 op_list_str = py_tf.TF_GetOpList(lib_handle)
NotFoundError: /usr/local/lib/python3.6/dist-packages/tf_sentencepiece/_sentencepiece_processor_ops.so.3.6/dist-packages/tf_sentencepiece/_sentencepiece_processor_ops.so.2.0.0-beta1: cannot open shared object file: No such file or directory
Je suis donc allé manuellement dans le répertoire pour vérifier si le fichier sentencepiece_processor_ops.so.2.0.0-beta existe ou non. Bizarrement, il était dans le dossier, mais dans un chemin un peu différent. Le colab essaie d'importer le fichier depuis /usr/local/lib/python3.6/dist-packages/tf_sentencepiece/_sentencepiece_processor_ops.so.3.6/dist-packages/tf_sentencepiece/_sentencepiece_processor_ops.so.2.0.0-beta1 (le chemin est bizarre, j'aurais dû le remarquer plus tôt...) mais le fichier existe en fait dans /usr/local/lib/python3.6/dist-packages/tf_sentencepiece/_sentencepiece_processor_ops.so.2.0.0-beta1
Comment se fait-il que le chemin soit bizarrement placé dans Colab ? Comment puis-je contourner ce problème ?