mila-iqia / atari-representation-learning

Code for "Unsupervised State Representation Learning in Atari"
https://arxiv.org/abs/1906.08226
MIT License
241 stars 50 forks source link

Pillow version problem #52

Closed DuaneNielsen closed 4 years ago

DuaneNielsen commented 4 years ago
python -m scripts.run_probe --method infonce-stdim --env-name Pong-v0

Traceback (most recent call last): File "/home/duane/anaconda3/envs/atari-representation-learning/lib/python3.7/runpy.py", line 183, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "/home/duane/anaconda3/envs/atari-representation-learning/lib/python3.7/runpy.py", line 109, in _get_module_details import(pkg_name) File "/home/duane/PycharmProjects/atari-representation-learning/scripts/init.py", line 1, in from .run_contrastive import train_encoder File "/home/duane/PycharmProjects/atari-representation-learning/scripts/run_contrastive.py", line 8, in from atariari.methods.dim_baseline import DIMTrainer File "/home/duane/PycharmProjects/atari-representation-learning/atariari/methods/dim_baseline.py", line 13, in from torchvision import transforms File "/home/duane/anaconda3/envs/atari-representation-learning/lib/python3.7/site-packages/torchvision/init.py", line 4, in from torchvision import datasets File "/home/duane/anaconda3/envs/atari-representation-learning/lib/python3.7/site-packages/torchvision/datasets/init.py", line 9, in from .fakedata import FakeData File "/home/duane/anaconda3/envs/atari-representation-learning/lib/python3.7/site-packages/torchvision/datasets/fakedata.py", line 3, in from .. import transforms File "/home/duane/anaconda3/envs/atari-representation-learning/lib/python3.7/site-packages/torchvision/transforms/init.py", line 1, in from .transforms import * File "/home/duane/anaconda3/envs/atari-representation-learning/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 17, in from . import functional as F File "/home/duane/anaconda3/envs/atari-representation-learning/lib/python3.7/site-packages/torchvision/transforms/functional.py", line 5, in from PIL import Image, ImageOps, ImageEnhance, PILLOW_VERSION ImportError: cannot import name 'PILLOW_VERSION' from 'PIL' (/home/duane/anaconda3/envs/atari-representation-learning/lib/python3.7/site-packages/PIL/init.py)

DuaneNielsen commented 4 years ago

Fixed by

conda install pillow=6.1
ankeshanand commented 4 years ago

I don't get this error when installing in a new conda env. Perhaps your earlier installed versions might be intervening.

Sidenote, you should use the NoFrameskip-v4 version of Atari envs since we already apply frameskip in the code. I have added a note in the README as well.

DuaneNielsen commented 4 years ago

This is fresh linux conda from anaconda.com https://www.anaconda.com/distribution/ 2019.10.

Normally, i manage all my packages with pip only, so no previous conda on the machine.

download and ran...

Anaconda3-2019.10-Linux-x86_64.sh

gives

(atari-representation-learning) duane@storm:~$ conda --version conda 4.7.12

Which version are you running?

ankeshanand commented 4 years ago

I can replicate the bug now. Looks like this is an issue with torchvision (https://github.com/pytorch/vision/issues/1712). That thread mentions are going to release a version that will resolve this.

In the meantime, your solution works, thanks for posting the fix!

DuaneNielsen commented 4 years ago

Just to rule out something funny in my environment, I ran up the build on circleci and can confirm that indeed I can reproduce this error...

https://app.circleci.com/jobs/github/DuaneNielsen/atari-representation-learning/26/parallel-runs/0/steps/0-105

Here is my .cicleci/config.yml https://github.com/DuaneNielsen/atari-representation-learning/blob/master/.circleci/config.yml

let me know if you are interested in setting up continuous integration at all. Happy to submit a pull request... it will probably make things a bit easier to troubleshoot...

full file below...

# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2
jobs:
  build:
    docker:
      - image: circleci/python:3.7.5

    working_directory: ~/repo

    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "requirements.txt" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-
      - run:
          name: install dependencies
          command: |
            sudo apt-get install -y wget
            wget https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh -O anaconda3.sh
            bash anaconda3.sh -b -p "$HOME"/anaconda3
            source /home/circleci/anaconda3/etc/profile.d/conda.sh
            conda activate base
            # Conda configuration
            conda config --set always_yes yes --set auto_update_conda false
            # Update conda
            conda update conda
            # Create test environment
            conda create -n test python=$PYTHON_VERSION
            conda activate test
            # PyTorch and scikit learn
            conda install pytorch torchvision -c pytorch
            conda install scikit-learn
            #gym atari
            pip install 'gym[atari]'
            # Baselines for Atari preprocessing
            # Tensorflow is a dependency, but you don't need to install the GPU version
            conda install tensorflow
            pip install git+git://github.com/openai/baselines
            # pytorch-a2c-ppo-acktr for RL utils
            pip install git+git://github.com/ankeshanand/pytorch-a2c-ppo-acktr-gail
            # Clone and install our package
            pip install -r requirements.txt
            pip install git+git://github.com/mila-iqia/atari-representation-learning.git
      - save_cache:
          paths:
            - ./venv
          key: v1-dependencies-{{ checksum "requirements.txt" }}

      # run tests!

      - run:
          name: run tests
          command: |
            source /home/circleci/anaconda3/etc/profile.d/conda.sh
            conda activate test
            conda --version
            python -m scripts.run_probe --method infonce-stdim --env-name PongNoFrameskip-v4
      - store_artifacts:
          path: test-reports
          destination: test-reports
DuaneNielsen commented 4 years ago

Great, thanks for taking the time to reproduce the error... let me know if you would like pull request. No is an OK answer ;)

ankeshanand commented 4 years ago

Thanks for double-checking the issue.

We haven't felt the need to have CI support just yet, but that might change in the future. It would also warrant writing tests and having a GPU to run the tests. So I suggest we revisit this thread if there are more use-cases for having CI in the future.

ankeshanand commented 4 years ago

torchvision 0.5 is now released which fixes this. https://github.com/pytorch/vision/releases

DuaneNielsen commented 4 years ago

Great news!

On Wed, Jan 15, 2020 at 4:56 PM Ankesh Anand notifications@github.com wrote:

torchvision 0.5 is now released which fixes this. https://github.com/pytorch/vision/releases

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mila-iqia/atari-representation-learning/issues/52?email_source=notifications&email_token=ACUOYLBWXB66RG4SPUI4KOTQ56WEHA5CNFSM4KFUCOZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJCLOYY#issuecomment-574928739, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUOYLAPD354GSX42JZ22CDQ56WEHANCNFSM4KFUCOZA .

-- Duane Broadcom 480 760 1559