cmusatyalab / openrtist

Live video frames from the camera are stylized to look like famous paintings.
Apache License 2.0
25 stars 20 forks source link

Running openrtist/server causes this error: AttributeError: 'module' object has no attribute 'ModuleDict' #13

Closed roymx closed 5 years ago

roymx commented 5 years ago

Using latest DockerHub image of cmusatyalab/openrtist Commit Source 897a0db created May 31st

Running the openrtist/server causes this error: root@95bc666fa48d:/# cd /openrtist/server root@95bc666fa48d:/openrtist/server# ./proxy.py -s 172.17.0.2:8021 Autodetect: failed to load OpenVINO; fallback to pyTorch Traceback (most recent call last): File "./proxy.py", line 65, in from torchvision import datasets File "/usr/local/lib/python2.7/dist-packages/torchvision/init.py", line 1, in from torchvision import models File "/usr/local/lib/python2.7/dist-packages/torchvision/models/init.py", line 10, in from . import segmentation File "/usr/local/lib/python2.7/dist-packages/torchvision/models/segmentation/init.py", line 1, in from .segmentation import * File "/usr/local/lib/python2.7/dist-packages/torchvision/models/segmentation/segmentation.py", line 1, in from .._utils import IntermediateLayerGetter File "/usr/local/lib/python2.7/dist-packages/torchvision/models/_utils.py", line 7, in class IntermediateLayerGetter(nn.ModuleDict): AttributeError: 'module' object has no attribute 'ModuleDict' root@95bc666fa48d:/openrtist/server#

In the container, the bundled version of /usr/local/lib/python2.7/dist-packages/torch/nn/modules/container.py does not contain function ModuleDict which is expected by torchvision.

Dockerfile (on DockerHub) shows that

On Torch side, version 0.4.1 is the first version containing ModuleDict https://github.com/pytorch/pytorch/blob/v0.4.1/torch/nn/modules/container.py

On Torchvision side, version 0.3.0 (latest) is the first version where class IntermediateLayerGetter(nn.ModuleDict) was introduced. https://github.com/pytorch/vision/blob/v0.3.0/torchvision/models/_utils.py

In conclusion, versions of Torch and Torchvision bundled in the latest DockerHub container seem out of sync/incompatible.

I'll try to provide a PR if I can get it to build locally.

a4anna commented 5 years ago

Hi @roymx - thanks for reporting this

I have updated the Dockerfile to use torchvision 0.2.2 . This resolves the error.

If you would like to use the latest torch version You can replace the models with the directory models_1p0 mv models_1p0 models and then install the latest pytorch version build with CUDA 8.0
pip install torch==1.1 -f https://download.pytorch.org/whl/cu80/stable torchvision==0.3.0

I will soon update the docker image on our Docker Hub page

roymx commented 5 years ago

Hello @a4anna,

NP I was about to test the same fix on my side 😊 Thanks for the prompt response & tips

roymx commented 5 years ago

I tested this DockerHub image again today and confirm that it is now functional.

image