python - 使用 CUDA GeForce9600GT 在 Ubuntu 服务器上执行 tensorflow

python - tensorflow execution on Ubuntu server with CUDA GeForce9600GT

我刚刚在 mac 上完成了 cifar10 tensorflow tutorial。这个教程激起了我对神经网络的热情,所以我搭建了一个Ubuntu服务器来大规模训练。

但是我无法在我的服务器上 运行 cifar10_train.py。我总是 运行 进入这个错误:

tensorflow源码路径:

~/python/tensorflow/tensorflow/tensorflow/

tensorflow virtualenv安装路径:

~/tensorflow/

命令:

source ~/tensorflow/bin/activate #activate virtualenv
python/tensorflow/tensorflow/tensorflow/models/image/cifar10/cifar10_train.py #the raw source code of tensorflow is in ~/python/tensorflow/tensorflow/tensorflow

错误:

Traceback (most recent call last):
  File "python/tensorflow/tensorflow/tensorflow/models/image/cifar10/cifar10_train.py", line 28, in <module>
    import tensorflow.python.platform
  File "/home/it13095/tensorflow/local/lib/python2.7/site-packages/tensorflow/__init__.py", line 4, in <module>
    from tensorflow.python import *
  File "/home/it13095/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 22, in <module>
    from tensorflow.python.client.client_lib import *
  File "/home/it13095/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/client_lib.py", line 35, in <module>
    from tensorflow.python.client.session import InteractiveSession
  File "/home/it13095/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 11, in <module>
    from tensorflow.python import pywrap_tensorflow as tf_session
  File "/home/it13095/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/home/it13095/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)

我在 virtualenv 中像 mac 一样安装了 tensorflow,并在执行脚本之前正确激活了它。 正如其他线程中的许多人所建议的那样,我已经升级了六个,但是我仍然遇到同样的错误。

更新 1 通过 github/tensorflow 上的问题线程后,我注意到这是一个涉及 cuda 的错误。我将这些添加到我的路径环境中:

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64"
export CUDA_HOME=/usr/local/cuda

我仍然 运行 出错,但它已缩短为以下内容:

Traceback (most recent call last):
File "cifar10_train.py", line 28, in <module>
import tensorflow.python.platform
ImportError: No module named tensorflow.python.platform

更新 2 正如有人建议的那样,我通过 pip 安装了 protobuf。由于一些奇怪的原因,错误再次发生变化:

Traceback (most recent call last):
  File "cifar10_train.py", line 28, in <module>
    import tensorflow.python.platform
  File "/home/it13095/tensorflow/local/lib/python2.7/site-packages/tensorflow/__init__.py", line 4, in <module>
    from tensorflow.python import *
  File "/home/it13095/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 13, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "/home/it13095/tensorflow/local/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 16, in <module>
    from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
  File "/home/it13095/tensorflow/local/lib/python2.7/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
    from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
  File "/home/it13095/tensorflow/local/lib/python2.7/site-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
    from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
  File "/home/it13095/tensorflow/local/lib/python2.7/site-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 22, in <module>
    serialized_pb=_b('\n,tensorflow/core/framework/tensor_shape.proto\x12\ntensorflow\"d\n\x10TensorShapeProto\x12-\n\x03\x64im\x18\x02 \x03(\x0b\x32 .tensorflow.TensorShapeProto.Dim\x1a!\n\x03\x44im\x12\x0c\n\x04size\x18\x01 \x01(\x03\x12\x0c\n\x04name\x18\x02 \x01(\tb\x06proto3')
TypeError: __init__() got an unexpected keyword argument 'syntax'

TensorFlow 目前需要 CUDA 工具包 7.0 和 cuDNN。

cuDNN 需要 cc 3.0 GPU,CUDA 工具包 7.0 需要 cc 2.0 GPU。

你的9600GT不满足这些requirements:

In order to build or run TensorFlow with GPU support, both Cuda Toolkit 7.0 and CUDNN 6.5 V2 from NVIDIA need to be installed.

TensorFlow GPU support requires having a GPU card with NVidia Compute Capability >= 3.5.

所以如果你想使用支持GPU的TensorFlow,你需要cc3.5或更高版本的GPU,并按照步骤正确安装需要的支持软件。或者,您可以在没有 GPU 支持的情况下安装 TensorFlow。