torchvision and tensorflow-gpu import error

Viewed 1528

Running this:

import torchvision
import tensorflow

Produces the error:

SystemError: google/protobuf/pyext/descriptor.cc:354: bad argument to internal function

However, swapping the order of the imports does not cause the error:

import tensorflow
import torchvision

Why is this happening?


Version info:

tensorflow-gpu=1.15.0
torchvision==0.5.0
2 Answers

Try reinstalling torchvision.


I have opened a ticket on tensorflow. My guess is that the order in which you install torchvision matters:

The fix is either to reinstall torchvision or to always import tensorflow first, as shown above. The issue is difficult to reproduce since fresh install fixes things. Perhaps it is related to the order in which packages are installed -- perhaps torchvision is somehow targeting older tensorflow-related libraries... and updating it again fixes this.

Related