Shmuma / ptan

PyTorch Agent Net: reinforcement learning toolkit for pytorch
MIT License
531 stars 165 forks source link

Is it possible to support PyTorch 1.5? #38

Closed thiagolcks closed 4 years ago

Nemolin commented 4 years ago

+1, is PTAN going to be deprecated?

billbai0102 commented 4 years ago

@thiagolcks @Nemolin Hey - I've come up with a temporary solution that seems to work for me. Here are the steps I took to allow it to work with the latest PyTorch and Torch-Ignite dist.

First, clone this repository, and unzip it (place it in any directory you'd like). When you're done, cd into ptan-master. Next, activate your conda environment. You can do this by typing conda activate EnvName Now, use a text editor (notepad will suffice), and edit requirements.txt and replace the requirements with this:

numpy
opencv-python
gym
atari-py
nose
torch
torch-ignite

When you're done, save the file and open setup.py, and replace the requirements list with requirements = ['torch', 'gym', 'atari-py', 'numpy', 'opencv-python']. Save the file when you're done. Lastly, all you have to do now is go to your activated conda environment from earlier and type in python setup.py install, and it should be good. I'm using PyTorch 1.5.1, and it works just fine for me.

Shmuma commented 4 years ago

Answering the original question: yes, it should be fairly straightforward to support latest pytorch. It might even work out of the box, as ptan is quite lightweight and doesn't use any advanced pytorch machinery (but I haven't tested this statement :)) .

But it still recommended to stick to requirements.txt supplied with book's repo at least for the beginning, as new versions of pytorch might contains subtle bugs or "features" which make code less efficient and/or break completely. During preparation of the second edition (which includes torch 0.4.1 -> 1.3 upgrade) I've seen various kinds of issues, including lack of convergence and 10-100 times performance drops). But it is always a good thing to experiment! Especially if you already familiar with the code and know the baseline convergence of the method.

Solution suggested by @billbai0102 above is quite risky, as removing pinning of version means "install the most recent version of the packages", which might be completely incompatible with the code. Again, it might work (or seems to work), but contains different weirdnesses in behaviour.