google-research / robotics_transformer

Apache License 2.0
1.29k stars 148 forks source link

ModuleNotFoundError: No module named 'tensorflow.contrib' #5

Open dbdxnuliba opened 1 year ago

dbdxnuliba commented 1 year ago

my env :

GPU driver (google_RT1) robot@robot:/usr/local$ ls -al cuda lrwxrwxrwx 1 root root 20 Sep 20 15:10 cuda -> /usr/local/cuda-10.0

(google_RT1) robot@robot:/usr/local$ nvidia-smi Fri Dec 16 11:11:13 2022
+-----------------------------------------------------------------------------+ | NVIDIA-SMI 418.88 Driver Version: 418.88 CUDA Version: 10.1 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce RTX 208... Off | 00000000:01:00.0 On | N/A | | 0% 39C P8 16W / 257W | 185MiB / 10986MiB | 5% Default | +-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | 0 1142 G /usr/lib/xorg/Xorg 183MiB | +-----------------------------------------------------------------------------+

python3:

(google_RT1) robot@robot:/usr/local$ python Python 3.8.15 (default, Nov 24 2022, 15:19:38) [GCC 11.2.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information.

(google_RT1) robot@robot:~/ref$ pip install -r robotics_transformer/requirements.txt 
Looking in indexes: http://pypi.douban.com/simple
Requirement already satisfied: absl-py>=0.5.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from -r robotics_transformer/requirements.txt (line 1)) (1.3.0)
Requirement already satisfied: numpy>=1.13.3 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from -r robotics_transformer/requirements.txt (line 2)) (1.23.5)
Requirement already satisfied: tensorflow>=1.13.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from -r robotics_transformer/requirements.txt (line 3)) (2.11.0)
Requirement already satisfied: tensorflow-serving-api>=1.13.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from -r robotics_transformer/requirements.txt (line 4)) (2.11.0)
Requirement already satisfied: gin-config>=0.1.4 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from -r robotics_transformer/requirements.txt (line 5)) (0.5.0)
Requirement already satisfied: tensorflow-probability>=0.6.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from -r robotics_transformer/requirements.txt (line 6)) (0.19.0)
Requirement already satisfied: tf-agents>=0.3.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from -r robotics_transformer/requirements.txt (line 7)) (0.15.0)
Requirement already satisfied: tf-slim>=1.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from -r robotics_transformer/requirements.txt (line 8)) (1.1.0)
Requirement already satisfied: flatbuffers>=2.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (22.12.6)
Requirement already satisfied: termcolor>=1.1.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (2.1.1)
Requirement already satisfied: tensorboard<2.12,>=2.11 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (2.11.0)
Requirement already satisfied: opt-einsum>=2.3.2 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (3.3.0)
Requirement already satisfied: packaging in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (22.0)
Requirement already satisfied: tensorflow-io-gcs-filesystem>=0.23.1 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (0.28.0)
Requirement already satisfied: h5py>=2.9.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (3.7.0)
Requirement already satisfied: libclang>=13.0.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (14.0.6)
Requirement already satisfied: six>=1.12.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (1.16.0)
Requirement already satisfied: typing-extensions>=3.6.6 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (4.4.0)
Requirement already satisfied: tensorflow-estimator<2.12,>=2.11.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (2.11.0)
Requirement already satisfied: gast<=0.4.0,>=0.2.1 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (0.4.0)
Requirement already satisfied: google-pasta>=0.1.1 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (0.2.0)
Requirement already satisfied: keras<2.12,>=2.11.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (2.11.0)
Requirement already satisfied: protobuf<3.20,>=3.9.2 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (3.19.6)
Requirement already satisfied: setuptools in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (65.5.0)
Requirement already satisfied: wrapt>=1.11.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (1.14.1)
Requirement already satisfied: astunparse>=1.6.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (1.6.3)
Requirement already satisfied: grpcio<2.0,>=1.24.3 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (1.51.1)
Requirement already satisfied: dm-tree in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow-probability>=0.6.0->-r robotics_transformer/requirements.txt (line 6)) (0.1.7)
Requirement already satisfied: decorator in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow-probability>=0.6.0->-r robotics_transformer/requirements.txt (line 6)) (5.1.1)
Requirement already satisfied: cloudpickle>=1.3 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorflow-probability>=0.6.0->-r robotics_transformer/requirements.txt (line 6)) (2.2.0)
Requirement already satisfied: gym<=0.23.0,>=0.17.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tf-agents>=0.3.0->-r robotics_transformer/requirements.txt (line 7)) (0.23.0)
Requirement already satisfied: pillow in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tf-agents>=0.3.0->-r robotics_transformer/requirements.txt (line 7)) (5.3.0)
Requirement already satisfied: pygame==2.1.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tf-agents>=0.3.0->-r robotics_transformer/requirements.txt (line 7)) (2.1.0)
Requirement already satisfied: wheel<1.0,>=0.23.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from astunparse>=1.6.0->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (0.37.1)
Requirement already satisfied: gym-notices>=0.0.4 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from gym<=0.23.0,>=0.17.0->tf-agents>=0.3.0->-r robotics_transformer/requirements.txt (line 7)) (0.0.8)
Requirement already satisfied: importlib-metadata>=4.10.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from gym<=0.23.0,>=0.17.0->tf-agents>=0.3.0->-r robotics_transformer/requirements.txt (line 7)) (5.1.0)
Requirement already satisfied: werkzeug>=1.0.1 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (2.2.2)
Requirement already satisfied: markdown>=2.6.8 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (3.4.1)
Requirement already satisfied: tensorboard-data-server<0.7.0,>=0.6.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (0.6.1)
Requirement already satisfied: google-auth<3,>=1.6.3 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (2.15.0)
Requirement already satisfied: requests<3,>=2.21.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (2.28.1)
Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (0.4.6)
Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (1.8.1)
Requirement already satisfied: rsa<5,>=3.1.4 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (4.9)
Requirement already satisfied: pyasn1-modules>=0.2.1 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (0.2.8)
Requirement already satisfied: cachetools<6.0,>=2.0.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (5.2.0)
Requirement already satisfied: requests-oauthlib>=0.7.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (1.3.1)
Requirement already satisfied: zipp>=0.5 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from importlib-metadata>=4.10.0->gym<=0.23.0,>=0.17.0->tf-agents>=0.3.0->-r robotics_transformer/requirements.txt (line 7)) (3.11.0)
Requirement already satisfied: charset-normalizer<3,>=2 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from requests<3,>=2.21.0->tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (2.1.1)
Requirement already satisfied: idna<4,>=2.5 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from requests<3,>=2.21.0->tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (3.4)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from requests<3,>=2.21.0->tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (1.26.13)
Requirement already satisfied: certifi>=2017.4.17 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from requests<3,>=2.21.0->tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (2022.9.24)
Requirement already satisfied: MarkupSafe>=2.1.1 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from werkzeug>=1.0.1->tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (2.1.1)
Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (0.4.8)
Requirement already satisfied: oauthlib>=3.0.0 in /home/robot/anaconda3/envs/google_RT1/lib/python3.8/site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.12,>=2.11->tensorflow>=1.13.0->-r robotics_transformer/requirements.txt (line 3)) (3.2.2)

Question: I has successfully configure env as your install step instruction:

pybullet build time: Dec 16 2022 10:07:09
Running tests under Python 3.8.15: /home/robot/anaconda3/envs/google_RT1/bin/python3.8
[ RUN      ] PoseEnvTest.test_PoseEnv
[       OK ] PoseEnvTest.test_PoseEnv
----------------------------------------------------------------------
Ran 1 test in 0.065s

but when I 
**(google_RT1) robot@robot:~/ref$ python -m tensor2robot.research.pose_env.pose_env_models_test**
it shows the following infomation:**ModuleNotFoundError: No module named 'tensorflow.contrib'**

(google_RT1) robot@robot:~/ref$ python -m tensor2robot.research.pose_env.pose_env_models_test
2022-12-16 11:06:35.907244: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-12-16 11:06:35.980578: W tensorflow/compiler/xla/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; LD_LIBRARY_PATH: /opt/ros/kinetic/share/euslisp/jskeus/eus//Linux64/lib:/opt/ros/kinetic/lib:/opt/ros/kinetic/lib/x86_64-linux-gnu:/usr/local/cuda/lib64
2022-12-16 11:06:35.980598: I tensorflow/compiler/xla/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2022-12-16 11:06:36.418803: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /opt/ros/kinetic/share/euslisp/jskeus/eus//Linux64/lib:/opt/ros/kinetic/lib:/opt/ros/kinetic/lib/x86_64-linux-gnu:/usr/local/cuda/lib64
2022-12-16 11:06:36.418856: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /opt/ros/kinetic/share/euslisp/jskeus/eus//Linux64/lib:/opt/ros/kinetic/lib:/opt/ros/kinetic/lib/x86_64-linux-gnu:/usr/local/cuda/lib64
2022-12-16 11:06:36.418865: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
Traceback (most recent call last):
  File "/home/robot/anaconda3/envs/google_RT1/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/robot/anaconda3/envs/google_RT1/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/robot/ref/tensor2robot/research/pose_env/pose_env_models_test.py", line 23, in <module>
    from tensor2robot.input_generators import default_input_generator
  File "/home/robot/ref/tensor2robot/input_generators/__init__.py", line 17, in <module>
    from tensor2robot.input_generators import abstract_input_generator
  File "/home/robot/ref/tensor2robot/input_generators/abstract_input_generator.py", line 25, in <module>
    from tensor2robot.models import abstract_model
  File "/home/robot/ref/tensor2robot/models/abstract_model.py", line 28, in <module>
    from tensor2robot.models import model_interface
  File "/home/robot/ref/tensor2robot/models/model_interface.py", line 33, in <module>
    from tensor2robot.preprocessors import abstract_preprocessor
  File "/home/robot/ref/tensor2robot/preprocessors/__init__.py", line 17, in <module>
    from tensor2robot.preprocessors import abstract_preprocessor
  File "/home/robot/ref/tensor2robot/preprocessors/abstract_preprocessor.py", line 22, in <module>
    from tensor2robot.utils import tensorspec_utils
  File "/home/robot/ref/tensor2robot/utils/tensorspec_utils.py", line 31, in <module>
    from tensorflow.contrib import framework as contrib_framework
**ModuleNotFoundError: No module named 'tensorflow.contrib'**
yunaHwang commented 1 year ago

Is this resolved? I have the same issue.

jaiber commented 9 months ago

I had to patch tensor2robot code to fix this

diff --git a/utils/tensorspec_utils.py b/utils/tensorspec_utils.py index 6331ec3..1f611a7 100644 --- a/utils/tensorspec_utils.py +++ b/utils/tensorspec_utils.py @@ -26,12 +26,14 @@ from six.moves import cPickle from six.moves import zip from tensor2robot.proto import t2r_pb2 import tensorflow.compat.v1 as tf +from tensorflow.python.util import nest +from tensorflow import TensorSpec as TSPEC

from google.protobuf import text_format -from tensorflow.contrib import framework as contrib_framework +#from tensorflow.contrib import framework as contrib_framework

-nest = contrib_framework.nest -TSPEC = contrib_framework.TensorSpec +#nest = contrib_framework.nest +#TSPEC = contrib_framework.TensorSpec

EXTRA_ASSETS_DIRECTORY = 'assets.extra' T2R_ASSETS_FILENAME = 't2r_assets.pbtxt'