目前,我正在尝试从同事那里获取现有模型,以便在Docker环境中使用TensorFlow。此过程的一个步骤是使用自定义版本替换TensorFlow user_ops file。但是,当我尝试在替换后导入TensorFlow时,我收到以下错误:
>>> import tensorflow
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 107, in <module>
from tensorflow.python.user_ops import user_ops
ImportError: No module named user_ops
然而,当我退出python并尝试:
less /usr/local/lib/python2.7/dist-packages/tensorflow/python/user_ops/user_ops.py
我得到了我打算在python中导入的user_ops文件。所以模块似乎在那里,与错误声称的相反。任何人都可以帮我找到问题所在吗?
编辑:
根据要求:
>python --version
Python 2.7.6
和
>python -c 'import tensorflow; print(tensorflow.__file__)'
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 107, in <module>
from tensorflow.python.user_ops import user_ops
ImportError: No module named user_ops
答案 0 :(得分:0)
问题解决了:
我通过替换整个user_ops文件夹替换了user_ops文件。但是我给出的文件夹不包含 init .py文件。这显然至关重要:将此文件的空版本添加到我的user_ops文件夹中解决了这个问题。