TensorRT messes up jpeg readers

To be concise, the following works:

import imageio
img = imageio.imread('myimage.jpg')

which returns

(400, 640, 3)

However, when I run the following:

import tensorrt
import imageio
img = imageio.imread('myimage.jpg')

I get the following error

ValueError: Could not load “”
Reason: “broken data stream when reading image file”
Please see documentation at: http://pillow.readthedocs.io/en/latest/installation.html#external-libraries

It is also the case with other jpeg readers like scipy.misc.imread.

Any thoughts on that?

PS: below is the version of some (possibly) relevant packages:

uff: 0.2.0
tensorflow: 1.7.0 (GPU)
PIL: 5.2.0
imageio: 2.4.1

Ubuntu 16.04
Tesla P100

Try changing the order of imports


I’m not able to repro your error.

root@02db90da60f1:/mnt# dpkg -l | grep nvinfer
ii  libnvinfer-dev              4.1.2-1+cuda9.0                       amd64        TensorRT development libraries and headers
ii  libnvinfer-samples          4.1.2-1+cuda9.0                       amd64        TensorRT samples and documentation
ii  libnvinfer4                 4.1.2-1+cuda9.0                       amd64        TensorRT runtime libraries
ii  python3-libnvinfer          4.1.2-1+cuda9.0                       amd64        Python 3 bindings for TensorRT
ii  python3-libnvinfer-dev      4.1.2-1+cuda9.0                       amd64        Python 3 development package for TensorRT
ii  python3-libnvinfer-doc      4.1.2-1+cuda9.0                       amd64        Documention and samples of python bindings for TensorRT
root@02db90da60f1:/mnt# cat working.py
import imageio
img = imageio.imread('source.jpg')
print(img.shape)root@02db90da60f1:/mnt# cat not.working.py
import tensorrt
import imageio
img = imageio.imread('source.jpg')
print(img.shape)root@02db90da60f1:/mnt# python working.py
(810, 1080, 3)
root@02db90da60f1:/mnt# python not.working.py
(810, 1080, 3)

Yes, this solved it. Thank you.
With the previous import order (first tensorrt and then imageio) I could read other image formats (like png) but not jpg.