使用tensorflow在pybullet中运行deepmimic示例时出错

问题描述

在运行使用tensorflow和OpenAI Gym和基准软件包的pybullet deep_mimic示例时,我遇到了此错误。该窗口与该漫游器一起显示了一秒钟,然后崩溃了。我正在使用python 3.8和tensorflow 2.3.1运行它。我没有Nvidia卡,但这似乎不是问题吗?

tensorflow.python.framework.errors_impl.FailedPreconditionError: Error while reading resource variable 
agent/resource/s_norm/mean_ph from Container: localhost. This Could mean that the variable was uninitialized. 

Not found: Container localhost does not exist. (Could not find resource: localhost/agent/resource/s_norm/mean_ph)
         [[{{node agent/resource/s_norm/ReadVariableOp_2}}]]
.
.
.
Errors may have originated from an input operation.
Input Source operations connected to node agent/resource/s_norm/ReadVariableOp_2:
 agent/resource/s_norm/mean_ph (defined at Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages
\pybullet_envs\deep_mimic\learning\tf_normalizer.py:63)

tf_normalizer.py:63处的代码

44:   def unnormalize_tf(self,norm_x):
45:     x = norm_x * self.std_tf + self.mean_tf
46:     return x
47: 
48:   def _build_resource_tf(self):
49:     self.count_tf = tf.get_variable(dtype=tf.int32,50:                                     name='count',51:                                     initializer=np.array([self.count],dtype=np.int32),52:                                     trainable=False)
53:     self.mean_tf = tf.get_variable(dtype=tf.float32,54:                                    name='mean',55:                                    initializer=self.mean.astype(np.float32),56:                                    trainable=False)
57:     self.std_tf = tf.get_variable(dtype=tf.float32,58:                                   name='std',59:                                   initializer=self.std.astype(np.float32),60:                                   trainable=False)
61: 
62:     self.count_ph = tf.get_variable(dtype=tf.int32,name='count_ph',shape=[1])
63:     self.mean_ph = tf.get_variable(dtype=tf.float32,name='mean_ph',shape=self.mean.shape)
64:     self.std_ph = tf.get_variable(dtype=tf.float32,name='std_ph',shape=self.std.shape)
65: 

完整的输出

(pyml) PS C:\Users\user\Downloads\lab\python\venvs> python -m pybullet_envs.deep_mimic.testrl --arg_file run_humanoid3d_backflip_args.txt
parentdir= C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages
2020-10-06 02:32:20.161043: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-10-06 02:32:20.165704: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
pybullet build time: Oct  6 2020 02:07:04
run_humanoid3d_backflip_args.txt
enable_draw= True
Initialization strategy: InitializationStrategy.RANDOM
starting thread 0
started testThreads thread 0 with threadHandle 00000000000006F4
argc=2
argv[0] = --unused
argv[1] = --start_demo_name=Physics Server
ExamplebrowserThreadFunc started
Version = 4.6.13543 Compatibility Profile Context 25.20.15002.58
vendor = ATI Technologies Inc.
Renderer = Radeon RX Vega M GH Graphics
b3Printf: Selected demo: Physics Server
starting thread 0
started MotionThreads thread 0 with threadHandle 0000000000002158
MotionThreadFunc thread started
motion_file= data/motions/humanoid3d_backflip.txt
LOADING humanoid!
b3Printf: b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,126]:

b3Printf: urdfdom: no axis elemement for Joint,defaulting to (1,0) axis
b3Printf: b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,126]:

b3Printf: chest
b3Printf: b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,126]:

b3Printf: neck
b3Printf: b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,126]:

b3Printf: right_hip
b3Printf: b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,126]:

b3Printf: right_ankle
b3Printf: b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,126]:

b3Printf: right_shoulder
b3Printf: b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,126]:

b3Printf: left_hip
b3Printf: b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,126]:

b3Printf: left_ankle
b3Printf: b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,126]:

b3Printf: left_shoulder
b3Printf: b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,126]:

b3Printf: left_shoulder
num_agents= 1

Num Agents: 1
len(agent_files)= 1
Agent 0: data/agents/ct_agent_humanoid_ppo.txt
2020-10-06 02:32:22.265256: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2020-10-06 02:32:22.269722: W tensorflow/stream_executor/cuda/cuda_driver.cc:312] Failed call to cuInit: UNKNowN ERROR (303)
2020-10-06 02:32:22.272419: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic @R_782_4045@ion for host: DESKTOP-22JP51K
2020-10-06 02:32:22.276323: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: DESKTOP-22JP51K
2020-10-06 02:32:22.281654: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (onednN)to use the following cpu instructions in performance-critical operations:  AVX2
To enable them in other operations,rebuild TensorFlow with the appropriate compiler flags.
2020-10-06 02:32:22.297342: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x24f9154db50 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-10-06 02:32:22.303706: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host,Default Version
state_offset= [ 0.5 -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.
 -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.
 -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.
 -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.
 -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.
 -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.
 -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.
 -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.
 -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.
 -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.
 -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.
 -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.
 -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.
 -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.  -0.
 -0. ]
state_scale= [0.5 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.
 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.
 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.
 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.
 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.
 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.
 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.
 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.
 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.
 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.
 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1. ]
Traceback (most recent call last):
  File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\tensorflow\python\client\session.py",line 1365,in _do_call
    return fn(*args)
  File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\tensorflow\python\client\session.py",line 1349,in _run_fn
    return self._call_tf_sessionrun(options,Feed_dict,fetch_list,File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\tensorflow\python\client\session.py",line 1441,in _call_tf_sessionrun
    return tf_session.TF_SessionRun_wrapper(self._session,options,tensorflow.python.framework.errors_impl.FailedPreconditionError: Error while reading resource variable agent/resource/s_norm/mean_ph from Container: localhost. This Could mean that the variable was uninitialized. Not found: Container localhost does not exist. (Could not find resource: localhost/agent/resource/s_norm/mean_ph)
         [[{{node agent/resource/s_norm/ReadVariableOp_2}}]]

During handling of the above exception,another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\python38\lib\runpy.py",line 194,in _run_module_as_main
    return _run_code(code,main_globals,None,File "C:\Program Files\python38\lib\runpy.py",line 87,in _run_code
    exec(code,run_globals)
  File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\testrl.py",line 97,in <module>
    world = build_world(args,True)
  File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\testrl.py",line 68,in build_world
    world = RLWorld(env,arg_parser)
  File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\rl_world.py",line 20,in __init__
    self.build_agents()
  File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\rl_world.py",line 75,in build_agents
    curr_agent = self._build_agent(i,curr_file)
  File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\rl_world.py",line 141,in _build_agent
    agent = AgentBuilder.build_agent(self,id,agent_file)
  File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\agent_builder.py",line 18,in build_agent
    agent = PPOAgent(world,json_data)
  File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\ppo_agent.py",line 32,in __init__
    super().__init__(world,json_data)
  File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\pg_agent.py",line 43,json_data)
  File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\tf_agent.py",line 22,json_data)
  File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\rl_agent.py",line 93,in __init__
    self._build_normalizers()
  File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\pg_agent.py",line 98,in _build_normalizers
    super()._build_normalizers()
  File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\tf_agent.py",line 106,in _build_normalizers
    self.s_norm.set_mean_std(-self.world.env.build_state_offset(self.id),File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\tf_normalizer.py",line 36,in set_mean_std
    self._update_resource_tf()
  File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\tf_normalizer.py",line 76,in _update_resource_tf
    self.sess.run(self._update_op,Feed_dict=Feed)
  File "C:\Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\tensorflow\python\client\session.py",line 957,in run
    result = self._run(None,fetches,options_ptr,line 1180,in _run
    results = self._do_run(handle,final_targets,final_fetches,line 1358,in _do_run
    return self._do_call(_run_fn,Feeds,targets,line 1384,in _do_call
    raise type(e)(node_def,op,message)
tensorflow.python.framework.errors_impl.FailedPreconditionError: Error while reading resource variable agent/resource/s_norm/mean_ph from Container: localhost. This Could mean that the variable was uninitialized. Not found: Container localhost does not exist. (Could not find resource: localhost/agent/resource/s_norm/mean_ph)
         [[node agent/resource/s_norm/ReadVariableOp_2 (defined at Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\tf_normalizer.py:67) ]]

Errors may have originated from an input operation.
Input Source operations connected to node agent/resource/s_norm/ReadVariableOp_2:
 agent/resource/s_norm/mean_ph (defined at Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\tf_normalizer.py:63)

Original stack trace for 'agent/resource/s_norm/ReadVariableOp_2':
  File "Program Files\python38\lib\runpy.py",File "Program Files\python38\lib\runpy.py",run_globals)
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\testrl.py",True)
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\testrl.py",arg_parser)
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\rl_world.py",in __init__
    self.build_agents()
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\rl_world.py",curr_file)
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\rl_world.py",agent_file)
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\agent_builder.py",json_data)
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\ppo_agent.py",json_data)
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\pg_agent.py",json_data)
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\tf_agent.py",json_data)
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\rl_agent.py",in __init__
    self._build_normalizers()
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\pg_agent.py",in _build_normalizers
    super()._build_normalizers()
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\tf_agent.py",line 100,in _build_normalizers
    self.s_norm = TFnormalizer(self.sess,'s_norm',self.get_state_size(),File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\tf_normalizer.py",in __init__
    self._build_resource_tf()
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\pybullet_envs\deep_mimic\learning\tf_normalizer.py",line 67,in _build_resource_tf
    self.mean_tf.assign(self.mean_ph),self.std_tf.assign(self.std_ph))
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py",line 857,in assign
    value_tensor = ops.convert_to_tensor(value,dtype=self.dtype)
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\tensorflow\python\framework\ops.py",line 1499,in convert_to_tensor
    ret = conversion_func(value,dtype=dtype,name=name,as_ref=as_ref)
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py",line 1909,in _dense_var_to_tensor
    return var._dense_var_to_tensor(dtype=dtype,as_ref=as_ref)  # pylint: disable=protected-access
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py",line 1326,in _dense_var_to_tensor
    return self.value()
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py",line 555,in value
    return self._read_variable_op()
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py",line 657,in _read_variable_op
    result = read_and_set_handle()
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py",line 647,in read_and_set_handle
    result = gen_resource_variable_ops.read_variable_op(self._handle,File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\tensorflow\python\ops\gen_resource_variable_ops.py",line 490,in read_variable_op
    _,_,_op,_outputs = _op_def_library._apply_op_helper(
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\tensorflow\python\framework\op_def_library.py",line 742,in _apply_op_helper
    op = g._create_op_internal(op_type_name,inputs,dtypes=None,File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\tensorflow\python\framework\ops.py",line 3477,in _create_op_internal
    ret = Operation(
  File "Users\user\Downloads\lab\python\venvs\pyml\lib\site-packages\tensorflow\python\framework\ops.py",line 1949,in __init__
    self._traceback = tf_stack.extract_stack()

numActiveThreads = 0
stopping threads
Thread with taskId 0 with handle 0000000000002158 exiting
Thread TERMINATED
finished
numActiveThreads = 0
btShutDownExamplebrowser stopping threads
Thread with taskId 0 with handle 00000000000006F4 exiting
Thread TERMINATED

可能是什么问题?

解决方法

因此可以在tensorflow 1.13和python 3.7上运行它。