danaugrs/huskarl

AttributeError: 'tensorflow.python.framework.ops.EagerTensor' object has no attribute 'squeeze'

Ellislee1 opened this issue · 2 comments

I've recently installed huskral and I've come accross this error running the demo cartpole:

$ python cartpole.py
2020-02-07 17:39:02.076013: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
C:\Users\Project Apollo\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\logger.py:30: UserWarning: WARN: Box bound precision lowered 
by casting to float32
  warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
2020-02-07 17:39:04.211558: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2020-02-07 17:39:04.232403: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce GTX 1080 computeCapability: 6.1
coreClock: 1.8475GHz coreCount: 20 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 298.32GiB/s
2020-02-07 17:39:04.244615: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-02-07 17:39:04.251647: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2020-02-07 17:39:04.263631: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2020-02-07 17:39:04.267875: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2020-02-07 17:39:04.274896: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll      
2020-02-07 17:39:04.280780: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2020-02-07 17:39:04.291507: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-02-07 17:39:04.296764: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2020-02-07 17:39:04.299782: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2020-02-07 17:39:04.304124: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1080 computeCapability: 6.1
coreClock: 1.8475GHz coreCount: 20 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 298.32GiB/s
2020-02-07 17:39:04.318416: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll       
2020-02-07 17:39:04.321747: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll        
2020-02-07 17:39:04.328921: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2020-02-07 17:39:04.332537: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll        
2020-02-07 17:39:04.335739: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll      
2020-02-07 17:39:04.338978: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll      
2020-02-07 17:39:04.348008: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-02-07 17:39:04.352672: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2020-02-07 17:39:04.832276: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1096] Device interconnect StreamExecutor with strength 1 edge matrix:   
2020-02-07 17:39:04.836232: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102]      0
2020-02-07 17:39:04.838399: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] 0:   N
2020-02-07 17:39:04.848517: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1241] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6349 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0, compute capability: 6.1)
2020-02-07 17:39:05.228721: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll        
Traceback (most recent call last):
  File "cartpole.py", line 47, in <module>
    sim.train(max_steps=5000, instances=instances, plot=plot_rewards)
  File "C:\Users\Project Apollo\AppData\Local\Programs\Python\Python37\lib\site-packages\huskarl\simulation.py", line 32, in train
    self._sp_train(max_steps, instances, visualize, plot)
  File "C:\Users\Project Apollo\AppData\Local\Programs\Python\Python37\lib\site-packages\huskarl\simulation.py", line 66, in _sp_train
    self.agent.train(step)
  File "C:\Users\Project Apollo\AppData\Local\Programs\Python\Python37\lib\site-packages\huskarl\agent\a2c.py", line 95, in train
    target_qvals[non_final_mask] = self.model.predict_on_batch(np.array(non_final_last_next_states))[:,-1].squeeze()
AttributeError: 'tensorflow.python.framework.ops.EagerTensor' object has no attribute 'squeeze'

Any idea why?

I was able to make it work by wrapping that line in tf. squeeze() as opposed to calling .squeeze() on the resulting tensor. Simple fix, though the original issue probably has something to do with a HuskaRL/Tensorflow version mismatch.

So I did some digging and it turns out that HuskaRL was/is compatable with tensorflow 2.0.0a0. I stepped back my tf version thanks to combing through log files after reinstalling both tf and HuskaRL out of order. So a proper fix for this would be roll back to tensorflow=2.0.0a0