Skip to content

How to incorporate OPENCV into pytorch docker image? #2186

@shwoo93

Description

@shwoo93

Hello

In order to be compatible with my local ubuntu version, I changed the version of ubuntu 16.04 to 14.04 in dockerfile which is provided and build the image from it. I just did as below.

FROM nvidia/cuda:8.0-cudnn6-devel-ubuntu14.04

RUN echo "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1404/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.list

I made the container and checked that torch and torchvision are well installed.
(Explicitly sourced the conda environment as well. source activate pytorch-py35)

After then, since I need opencv for my own code I tried to install opencv3 by the command below.

conda install -c menpo opencv3

However above command requires to downgrade the numpy and scipy packages.

The following packages will be DOWNGRADED:

numpy:      1.13.1-py35_0            --> 1.11.3-py35_0
scipy:      0.19.1-np113py35_0       --> 0.19.0-np111py35_0**

If I just execute the above command for opencv, it results in error for importing torch then.
Giving,

RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
Traceback (most recent call last):
File "", line 1, in
File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/torch/init.py", line 53, in
from torch._C import *
ImportError: numpy.core.multiarray failed to import

So I just upgraded using pip
pip install numpy --upgrade
pip install scipy --upgrade

Then it gives below error.
ImportError: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory

So I installed libgtk2.0 with the below command
sudo apt-get install libgtk2.0-0:i386

And finally it seems to work with opencv

1 . I am wondering is this right way to incorporate opencv into pytorch docker image.
Is there any nice way to figure out this problem
?

2. Additionally, I am curious about whether the docker file provided gives current master version of pytorch.

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions