简体   繁体   中英

torchvision and tensorflow-gpu import error

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

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.

This fix:

import tensorflow  # BEFORE all other imports

import torchvision

It works for me.

Source: https://github.com/tensorflow/tensorflow/issues/48797

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM