简体   繁体   English

torchvision 和 tensorflow-gpu 导入错误

[英]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 SystemError:google/protobuf/pyext/descriptor.cc:354:内部 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 .尝试重新安装torchvision


I have opened a ticket on tensorflow .我在tensorflow上开了一张票。 My guess is that the order in which you install torchvision matters:我的猜测是您安装torchvision的顺序很重要:

The fix is either to reinstall torchvision or to always import tensorflow first, as shown above.修复方法是重新安装torchvision或始终首先导入tensorflow ,如上所示。 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.也许这与安装软件包的顺序有关——也许torchvision以某种方式针对较旧的tensorflow相关库......并再次更新它可以解决这个问题。

This fix:此修复:

import tensorflow  # BEFORE all other imports

import torchvision

It works for me.这个对我有用。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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