Tensorflow integrate with baselines package in OpenAI gym

Hi All,

Has anyone installed baselines packages in Jetson TX2? https://github.com/openai/baselines
I have problems during install baselines packages and looking forward to received advice from everyone. The detail of my issue as below:

nvidia@tegra-ubuntu:~/baselines$ pip install -e .
Obtaining file:///home/nvidia/baselines
Complete output from command python setup.py egg_info:
running egg_info
creating baselines.egg-info
writing top-level names to baselines.egg-info/top_level.txt
writing dependency_links to baselines.egg-info/dependency_links.txt
writing requirements to baselines.egg-info/requires.txt
writing baselines.egg-info/PKG-INFO
writing manifest file ‘baselines.egg-info/SOURCES.txt’
warning: manifest_maker: standard file ‘-c’ not found

reading manifest file ‘baselines.egg-info/SOURCES.txt’
writing manifest file ‘baselines.egg-info/SOURCES.txt’
Traceback (most recent call last):
File “”, line 1, in
File “/home/nvidia/baselines/setup.py”, line 63, in
assert StrictVersion(re.sub(r’-?rc\d+$’, ‘’, tf_pkg.version)) >= StrictVersion(‘1.4.0’)
File “/usr/lib/python3.5/distutils/version.py”, line 40, in init
self.parse(vstring)
File “/usr/lib/python3.5/distutils/version.py”, line 137, in parse
raise ValueError(“invalid version number ‘%s’” % vstring)
ValueError: invalid version number ‘1.9.0+nv18.8’


Command “python setup.py egg_info” failed with error code 1 in /home/nvidia/baselines/

nvidia@tegra-ubuntu:~/baselines$

When I tried to build install package it appear issue with version of tensorflow “1.9.0+nv18.8”. I guest that this baselines package need a version such as “1.9.0”. Based on your expert, I’m looking forward to receive your advice and help me how to install baselines package in Jetson TX2?

Thanks everyone so much!

Hi,

Could you try if this command helps?

pip install --upgrade setuptools

Thanks.

Hello AastaLLL,

Thank you so much for your advice! I tried your commands, unfortunately the issue still exist as below:
nvidia@tegra-ubuntu:~ pip install --upgrade setuptools --user /usr/local/lib/python2.7/dist-packages/pip-18.1-py2.7.egg/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown. warnings.warn(warning, RequestsDependencyWarning) Requirement already up-to-date: setuptools in ./.local/lib/python2.7/site-packages (40.6.2) nvidia@tegra-ubuntu:~ cd baselines
nvidia@tegra-ubuntu:~/baselines$ pip install -e .
/usr/local/lib/python2.7/dist-packages/pip-18.1-py2.7.egg/pip/_vendor/requests/init.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
warnings.warn(warning, RequestsDependencyWarning)
Obtaining file:///home/nvidia/baselines
Complete output from command python setup.py egg_info:
This Python is only compatible with Python 3, but you are running Python 2. The installation will likely fail.
running egg_info
writing requirements to baselines.egg-info/requires.txt
writing baselines.egg-info/PKG-INFO
writing top-level names to baselines.egg-info/top_level.txt
writing dependency_links to baselines.egg-info/dependency_links.txt
reading manifest file ‘baselines.egg-info/SOURCES.txt’
writing manifest file ‘baselines.egg-info/SOURCES.txt’
Traceback (most recent call last):
File “”, line 1, in
File “/home/nvidia/baselines/setup.py”, line 63, in
assert StrictVersion(re.sub(r’-?rc\d+$’, ‘’, tf_pkg.version)) >= StrictVersion(‘1.4.0’)
File “/usr/lib/python2.7/distutils/version.py”, line 40, in init
self.parse(vstring)
File “/usr/lib/python2.7/distutils/version.py”, line 107, in parse
raise ValueError, “invalid version number ‘%s’” % vstring
ValueError: invalid version number ‘1.9.0+nv18.8’

----------------------------------------

Command “python setup.py egg_info” failed with error code 1 in /home/nvidia/baselines/
nvidia@tegra-ubuntu:~/baselines$

Even when I install baselines in virtual environment it stills have issue as below:

nvidia@tegra-ubuntu:~ source env_tensorflow/bin/activate (env_tensorflow) nvidia@tegra-ubuntu:~ pip install baselines
Collecting baselines
Using cached https://files.pythonhosted.org/packages/f1/bd/d7695f0e5649658b43eabf10d1efa11c70a30ce532faef994c8b7172a744/baselines-0.1.5.tar.gz
Requirement already satisfied: gym[atari,classic_control,mujoco,robotics] in ./env_tensorflow/lib/python3.5/site-packages (from baselines) (0.10.9)
Requirement already satisfied: scipy in ./env_tensorflow/lib/python3.5/site-packages (from baselines) (1.1.0)
Collecting tqdm (from baselines)
Using cached https://files.pythonhosted.org/packages/91/55/8cb23a97301b177e9c8e3226dba45bb454411de2cbd25746763267f226c2/tqdm-4.28.1-py2.py3-none-any.whl
Collecting joblib (from baselines)
Using cached https://files.pythonhosted.org/packages/0d/1b/995167f6c66848d4eb7eabc386aebe07a1571b397629b2eac3b7bebdc343/joblib-0.13.0-py2.py3-none-any.whl
Collecting zmq (from baselines)
Using cached https://files.pythonhosted.org/packages/6e/78/833b2808793c1619835edb1a4e17a023d5d625f4f97ff25ffff986d1f472/zmq-0.0.0.tar.gz
Collecting dill (from baselines)
Using cached https://files.pythonhosted.org/packages/6f/78/8b96476f4ae426db71c6e86a8e6a81407f015b34547e442291cd397b18f3/dill-0.2.8.2.tar.gz
Collecting progressbar2 (from baselines)
Using cached https://files.pythonhosted.org/packages/4f/6f/acb2dd76f2c77527584bd3a4c2509782bb35c481c610521fc3656de5a9e0/progressbar2-3.38.0-py2.py3-none-any.whl
Requirement already satisfied: mpi4py in ./env_tensorflow/lib/python3.5/site-packages (from baselines) (3.0.0)
Collecting cloudpickle (from baselines)
Using cached https://files.pythonhosted.org/packages/fc/87/7b7ef3038b4783911e3fdecb5c566e3a817ce3e890e164fc174c088edb1e/cloudpickle-0.6.1-py2.py3-none-any.whl
Collecting tensorflow>=1.4.0 (from baselines)
Could not find a version that satisfies the requirement tensorflow>=1.4.0 (from baselines) (from versions: )
No matching distribution found for tensorflow>=1.4.0 (from baselines)

(env_tensorflow) nvidia@tegra-ubuntu:~$

I installed tensorflow in Jetson TX2!
I’m looking forward to hear your advice~
Thank you so much,

Hi,

You need to use TensorFlow package newer than v1.4.0 to get OpenAI baselines works:

Could not find a version that satisfies the requirement tensorflow>=1.4.0 (from baselines) (from versions: )
No matching distribution found for tensorflow>=1.4.0 (from baselines)

Have you installed it on your device?
We have an official release for v1.9.0 here:
https://devtalk.nvidia.com/default/topic/1038957/jetson-tx2/tensorflow-for-jetson-tx2-/post/5278617/#5278617

Thanks.

Hello AastaLLL,

Thank you so much for your advice! I tried again with your suggestion with the result as below:

  • Tensorflow checked in Jetson TX2:
    nvidia@tegra-ubuntu:~$ python2
    Python 2.7.12 (default, Nov 12 2018, 14:36:49)
    [GCC 5.4.0 20160609] on linux2
    Type “help”, “copyright”, “credits” or “license” for more information.

import tensorflow
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xa
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xa
/usr/local/lib/python2.7/dist-packages/requests/init.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
warnings.warn(warning, RequestsDependencyWarning)

import tensorflow as tf
quit()
nvidia@tegra-ubuntu:~$ python3
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import tensorflow as tf
quit()

Based on that, I think tensorflow package was completed install in Jetson TX2.

However when I tried to install baselines packages it still have problems as below:
nvidia@tegra-ubuntu:~ source env_tensorflow/bin/activate (env_tensorflow) nvidia@tegra-ubuntu:~ pip install baselines
Collecting baselines
Using cached https://files.pythonhosted.org/packages/f1/bd/d7695f0e5649658b43eabf10d1efa11c70a30ce532faef994c8b7172a744/baselines-0.1.5.tar.gz
Requirement already satisfied: gym[atari,classic_control,mujoco,robotics] in ./env_tensorflow/lib/python3.5/site-packages (from baselines) (0.10.9)
Requirement already satisfied: scipy in ./env_tensorflow/lib/python3.5/site-packages (from baselines) (1.1.0)
Collecting tqdm (from baselines)
Using cached https://files.pythonhosted.org/packages/91/55/8cb23a97301b177e9c8e3226dba45bb454411de2cbd25746763267f226c2/tqdm-4.28.1-py2.py3-none-any.whl
Collecting joblib (from baselines)
Using cached https://files.pythonhosted.org/packages/0d/1b/995167f6c66848d4eb7eabc386aebe07a1571b397629b2eac3b7bebdc343/joblib-0.13.0-py2.py3-none-any.whl
Collecting zmq (from baselines)
Using cached https://files.pythonhosted.org/packages/6e/78/833b2808793c1619835edb1a4e17a023d5d625f4f97ff25ffff986d1f472/zmq-0.0.0.tar.gz
Collecting dill (from baselines)
Using cached https://files.pythonhosted.org/packages/6f/78/8b96476f4ae426db71c6e86a8e6a81407f015b34547e442291cd397b18f3/dill-0.2.8.2.tar.gz
Collecting progressbar2 (from baselines)
Using cached https://files.pythonhosted.org/packages/4f/6f/acb2dd76f2c77527584bd3a4c2509782bb35c481c610521fc3656de5a9e0/progressbar2-3.38.0-py2.py3-none-any.whl
Requirement already satisfied: mpi4py in ./env_tensorflow/lib/python3.5/site-packages (from baselines) (3.0.0)
Collecting cloudpickle (from baselines)
Using cached https://files.pythonhosted.org/packages/fc/87/7b7ef3038b4783911e3fdecb5c566e3a817ce3e890e164fc174c088edb1e/cloudpickle-0.6.1-py2.py3-none-any.whl
Collecting tensorflow>=1.4.0 (from baselines)
Could not find a version that satisfies the requirement tensorflow>=1.4.0 (from baselines) (from versions: )
No matching distribution found for tensorflow>=1.4.0 (from baselines)
(env_tensorflow) nvidia@tegra-ubuntu:~$

I’m looking forward to hear your advice~
Kind regards,

Dear AastaLLL,

Could you please refer my question as previous?
https://devtalk.nvidia.com/default/topic/1035805/deep-reinforcement-learning-algorithm-on-jetson-tx2/

I used the solution to build baselines package directly from this link:
https://github.com/openai/baselines
"
I checked again with baselines package and the code. I think the issue can come from version number “1.9.0+nv18.8”. It can lead to baselines package cannot find the version satisfy with Jetson TX. Therefore, is this possible to you to change the version from “1.9.0+nv18.8” to “1.9.0”
"

Could you please take a look and give me your advice?
Thank you so much!

Hi,

This error indicates the incompatible numpy version:

RuntimeError: module compiled against API version 0xc but this version of numpy is 0xa

And it cause an issue on your TensorFlow installation.

Have you ever updated the numpy package?
Could you also help to check the minimal numpy version in baselines?

If the default numpy version is acceptable, it’s recommended to reset the environment via reflashing.
And install our official TensorFlow package.

Thanks.

Hello AastaLLL,

I’ll reflash Jetson and environment and update to you soon!

Thank you so much~
Huong Do Van

Hello AastaLLL,
I re-flash jetpack 3.3 in Jetson TX2 and re-install tensorflow version 1.12 as link below:

https://github.com/peterlee0127/tensorflow-nvJetson
https://devtalk.nvidia.com/default/topic/1031300/jetson-tx2/tensorflow-1-10-wheel-with-jetpack-3-3/

here is the result:
nvidia@tegra-ubuntu:~$ python3
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import tensorflow
import tensorflow as tf

and, I completed install OpenCV in Jetson TX2 as the link below:
https://github.com/jetsonhacks/buildOpenCVTX2

Here is the result:
nvidia@tegra-ubuntu:~$ python3
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import tensorflow
import tensorflow as tf
quit()
nvidia@tegra-ubuntu:~$ python2
Python 2.7.12 (default, Nov 12 2018, 14:36:49)
[GCC 5.4.0 20160609] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import cv2
quit()
nvidia@tegra-ubuntu:~$ python3
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import cv2
quit()
nvidia@tegra-ubuntu:~$

I think for both of them are work fine.
Now I install baselines openai, it appear with this issue as below:
nvidia@tegra-ubuntu:~ cd baselines/ nvidia@tegra-ubuntu:~/baselines pip install -e .
Obtaining file:///home/nvidia/baselines
Collecting gym (from baselines==0.1.5)
Using cached https://files.pythonhosted.org/packages/d4/22/4ff09745ade385ffe707fb5f053548f0f6a6e7d5e98a2b9d6c07f5b931a7/gym-0.10.9.tar.gz
Collecting scipy (from baselines==0.1.5)
Using cached https://files.pythonhosted.org/packages/07/76/7e844757b9f3bf5ab9f951ccd3e4a8eed91ab8720b0aac8c2adcc2fdae9f/scipy-1.1.0.tar.gz
Collecting tqdm (from baselines==0.1.5)
Using cached https://files.pythonhosted.org/packages/91/55/8cb23a97301b177e9c8e3226dba45bb454411de2cbd25746763267f226c2/tqdm-4.28.1-py2.py3-none-any.whl
Collecting joblib (from baselines==0.1.5)
Using cached https://files.pythonhosted.org/packages/0d/1b/995167f6c66848d4eb7eabc386aebe07a1571b397629b2eac3b7bebdc343/joblib-0.13.0-py2.py3-none-any.whl
Collecting dill (from baselines==0.1.5)
Using cached https://files.pythonhosted.org/packages/6f/78/8b96476f4ae426db71c6e86a8e6a81407f015b34547e442291cd397b18f3/dill-0.2.8.2.tar.gz
Collecting progressbar2 (from baselines==0.1.5)
Using cached https://files.pythonhosted.org/packages/ad/51/0e1b51e0ece81220ff14bedd2634cbfd3bbefadf7a3ca70bf29ba3c73247/progressbar2-3.39.0-py2.py3-none-any.whl
Collecting cloudpickle (from baselines==0.1.5)
Using cached https://files.pythonhosted.org/packages/fc/87/7b7ef3038b4783911e3fdecb5c566e3a817ce3e890e164fc174c088edb1e/cloudpickle-0.6.1-py2.py3-none-any.whl
Collecting click (from baselines==0.1.5)
Using cached https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl
Collecting opencv-python (from baselines==0.1.5)
Could not find a version that satisfies the requirement opencv-python (from baselines==0.1.5) (from versions: )

No matching distribution found for opencv-python (from baselines==0.1.5)
nvidia@tegra-ubuntu:~/baselines$

I tried with several ways to solve this issue! I don’t know why I cannot install baselines packages in Jetson TX2. Base on your expertise in this, please help me your suggestions!

Thank you so much,

Hi,

Could you try this script to install OpenCV?
https://github.com/AastaNV/JEP/blob/master/script/install_opencv3.4.0_TX2.sh

We also test baselines on our environment.
Will update more information with you later.

Thanks.

Hi,

You can find opencv-python for aarch64 here:
https://pypi.org/project/opencv-python-aarch64/#files

Thanks.

Hi,

I had the same problem when trying to installing one of the samples from OpenAI on Xavier.

  1. I installed OpenCV for Xavier as described on jetsonhacks site.

  2. OpenAI on GitHub has a version of baselines you have to use. Clone it but it failed on my installation because it couldn’t find the package OpenCV-python package.

  3. Edit the setup.py in baselines project to exclude the ‘opencv-python’ in ‘install_requires’. OpenCV has already been installed above. After saving setup.py, run install of baselines as described in the README on GitHub

  4. ‘numpy’ might be installed as ‘1.16.1’. I had to uninstall and install the ‘1.15.4’ version.

  5. switching back to ‘large-scale-curiosity’ project, and executing ‘run.py’, it fails identifying the available GPU’s on the Xavier.
    Edit the utils.py and add the following to the end of the existing get_available_gpus() function

add to the top of the utils.py file:
‘from tensorflow.python.client import device_lib’

replace the Exception line in the ‘get_available_gpus’ function with the following:

local_device_protos = device_lib.list_local_devices()
return [x.name for x in local_device_protos if x.device_type == 'GPU']
  1. The project uses a lot of RAM so make sure to add a swap drive. I use the script from jetsonhacks/postFlashTX1 project on GitHub. Adding 8G’s should be enough.

Cool! Thanks for sharing.