pytorch / tutorials

PyTorch tutorials.
https://pytorch.org/tutorials/
BSD 3-Clause "New" or "Revised" License
8.22k stars 4.07k forks source link

'TimeLimit' object has no attribute 'x_threshold' error running reinforcement_q_learning.ipynb tutorial #66

Closed NataliaDiaz closed 7 years ago

NataliaDiaz commented 7 years ago
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-2f6091ee96f6> in <module>()
     37 
     38 env.reset()
---> 39 plt.imshow(get_screen().squeeze(0).permute(
     40     1, 2, 0).numpy(), interpolation='none')
     41 plt.show()

<ipython-input-5-2f6091ee96f6> in get_screen()
     19     screen = screen[:, 160:320]
     20     view_width = 320
---> 21     cart_location = get_cart_location()
     22     if cart_location < view_width // 2:
     23         slice_range = slice(view_width)

<ipython-input-5-2f6091ee96f6> in get_cart_location()
      8 
      9 def get_cart_location():
---> 10     world_width = env.x_threshold * 2
     11     scale = screen_width / world_width
     12     return int(env.state[0] * scale + screen_width / 2.0)  # MIDDLE OF CART

AttributeError: 'TimeLimit' object has no attribute 'x_threshold'
chsasank commented 7 years ago

Duplicate of #29. Fixing.

chsasank commented 7 years ago

Please download and report if you have any errors. Thanks.

NataliaDiaz commented 7 years ago

Thanks, now I get : free(): invalid pointer error running both the notebook and reinforcement_q_learning.py (the kernels dies and restarts):

~/notebooks$ jupyter notebook
[I 09:22:24.158 NotebookApp] Serving notebooks from local directory: /home/natalia/notebooks
[I 09:22:24.158 NotebookApp] 0 active kernels 
[I 09:22:24.158 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=e70854c1d5423883eda6325c1b503efbebafff06ad9e0177
[I 09:22:24.158 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 09:22:24.160 NotebookApp] 

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=e70854c1d5423883eda6325c1b503efbebafff06ad9e0177
Created new window in existing browser session.
[I 09:22:24.727 NotebookApp] Accepting one-time-token-authenticated connection from 127.0.0.1
[I 09:22:28.993 NotebookApp] Kernel started: 7f72071a-3b5a-4f39-86f0-d59cdc01aaee
[W 09:22:29.307 NotebookApp] 404 GET /static/components/MathJax/jax/element/mml/optable/BasicLatin.js?rev=2.6.0 (127.0.0.1) 8.88ms referer=http://localhost:8888/notebooks/reinforcement_q_learning.ipynb
[W 09:22:35.066 NotebookApp] Notebook face_recognition.ipynb is not trusted
[I 09:22:35.437 NotebookApp] Kernel started: 896f0bbe-e196-4047-b2c1-2736eef40679
*** Error in `/home/natalia/anaconda2/bin/python': free(): invalid pointer: 0x00007fa045d28ae0 ***
[I 09:22:37.993 NotebookApp] KernelRestarter: restarting kernel (1/5)
WARNING:root:kernel 7f72071a-3b5a-4f39-86f0-d59cdc01aaee restarted
[I 09:23:29.670 NotebookApp] 302 GET /?token=e70854c1d5423883eda6325c1b503efbebafff06ad9e0177 (127.0.0.1) 0.39ms
[W 09:23:33.148 NotebookApp] 404 GET /static/components/MathJax/jax/element/mml/optable/BasicLatin.js?rev=2.6.0 (127.0.0.1) 1.59ms referer=http://localhost:8888/notebooks/reinforcement_q_learning.ipynb
*** Error in `/home/natalia/anaconda2/bin/python': free(): invalid pointer: 0x00007f6a5a17dae0 ***
[I 09:23:40.999 NotebookApp] KernelRestarter: restarting kernel (1/5)
WARNING:root:kernel 7f72071a-3b5a-4f39-86f0-d59cdc01aaee restarted

~/notebooks$ python reinforcement_q_learning.py 
[2017-04-18 09:24:11,190] Making new env: CartPole-v0
*** Error in `python': free(): invalid pointer: 0x00007f83611bbae0 ***
Aborted (core dumped)
chsasank commented 7 years ago

I cannot reproduce the issue on my mac:

python version: Python 3.6.0 |Anaconda 4.3.0 (x86_64)| (default, Dec 23 2016, 13:19:00) os: 10.11.6

$ python reinforcement_q_learning.py 
[2017-04-19 23:56:45,919] Making new env: CartPole-v0

It's not unlikely that this issue can be reproduced on ubuntu. Are you using ubuntu? If so, I will run it on a ubuntu box tomorrow.

NataliaDiaz commented 7 years ago

This is in Ubuntu 14.04 using Python 2.7.

chsasank commented 7 years ago

Indeed, I can reproduce this on ubuntu 16.04, python 3.5.2 and gym 0.8.1. Here's the full backtrace of segfault(?): backtrace.txt

I need checked that type(env) and made sure it's gym.envs.classic_control.CartPoleEnv. This means it should work as expected.

I think the issue is in gym. Can you please file an issue at openai/gym with the script and backtrace?

EDIT: looks like GPU issue. I ran on a machine without a gpu (same ubuntu 16.04, python 3.5.2 and gym 0.8.1) without any errors.

Thanks, Sasank.