tensorflow - 使用 Pascal GPU 的 "Deep MNIST for Experts"精度极低

标签 tensorflow

首先,我有点不确定我是否应该在 Github 上或这里问这个问题,但由于我不确定我选择使用 stackoverflow。

我最近购买了 Nvidia GTX 1070,想用它尝试一下 TensorFlow。我正在使用全新安装的 Ubuntu 16.04、来自“图形驱动程序团队”PPA 的 nvidia-367 驱动程序、nvidia-cuda-toolkit 7.5.18-0ubuntu1 和 cuDNN v4(2016 年 2 月 10 日)。

Tensorflow是按照https://www.tensorflow.org/versions/r0.9/get_started/os_setup.html安装的遵循“Virtualenv 安装”,使用此 TF_BINARY_URL:

# Ubuntu/Linux 64-bit, GPU enabled, Python 2.7 
# Requires CUDA toolkit 7.5 and CuDNN v4. For other versions, see "Install from sources" below.
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl

第一个教程似乎工作正常,我运行了一些其他示例模型,它们似乎也工作正常,但由于某种原因,我在“专家的深度 MNIST”中获得了大约 9.5% 的准确度教程。

起初我以为我在复制粘贴代码时犯了一些错误,并花了一些时间尝试调试它但无济于事。然后我在github上发现了这个问题https://github.com/tensorflow/tensorflow/issues/2781并尝试下载他的代码,但准确率没有接近 90%。我还尝试修复代码中的错误,因此训练步骤每次迭代都会运行,但没有成功。

这是我在 github 上运行上述问题的 tut.py 得到的输出,修改为在循环的每次迭代上运行 train_step:

$ python -i tut.py
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.so locally
>>> conv_net()
Extracting MNIST_data/train-images-idx3-ubyte.gz
Extracting MNIST_data/train-labels-idx1-ubyte.gz
Extracting MNIST_data/t10k-images-idx3-ubyte.gz
Extracting MNIST_data/t10k-labels-idx1-ubyte.gz
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:924] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
I tensorflow/core/common_runtime/gpu/gpu_init.cc:102] Found device 0 with properties:
name: GeForce GTX 1070
major: 6 minor: 1 memoryClockRate (GHz) 1.7715
pciBusID 0000:01:00.0
Total memory: 7.92GiB
Free memory: 7.46GiB
I tensorflow/core/common_runtime/gpu/gpu_init.cc:126] DMA: 0
I tensorflow/core/common_runtime/gpu/gpu_init.cc:136] 0:   Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:806] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0)
step 0, training accuracy 0.14
step 100, training accuracy 0.1
step 200, training accuracy 0.16
step 300, training accuracy 0.12
step 400, training accuracy 0.1
step 500, training accuracy 0.08

   [....]

step 19500, training accuracy 0.18
step 19600, training accuracy 0.06
step 19700, training accuracy 0.1
step 19800, training accuracy 0.12
step 19900, training accuracy 0.08
W tensorflow/core/common_runtime/bfc_allocator.cc:213] Ran out of memory trying to allocate 5.84GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory is available.
test accuracy 0.0954

我还可以补充一点,我相当确定我不久前使用较旧的 GPU 运行了本教程,并且没有任何问题,所以不知怎的,我感觉 Pascal 架构的某些东西没有得到正确支持。更奇怪的是,一些更复杂的模型,如 CNN 和 RNN“教程”/示例(似乎)运行良好。

编辑:

我安装的CPU版本使用

# Ubuntu/Linux 64-bit, CPU only, Python 2.7
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl

并运行 1000 次迭代(而不是 20000 次)给出以下结果:

$ python -i tut.py 
>>> conv_net()
Extracting MNIST_data/train-images-idx3-ubyte.gz
Extracting MNIST_data/train-labels-idx1-ubyte.gz
Extracting MNIST_data/t10k-images-idx3-ubyte.gz
Extracting MNIST_data/t10k-labels-idx1-ubyte.gz
step 0, training accuracy 0.14
step 100, training accuracy 0.88
step 200, training accuracy 0.88
step 300, training accuracy 0.82
step 400, training accuracy 0.94
step 500, training accuracy 0.92
step 600, training accuracy 0.98
step 700, training accuracy 0.94
step 800, training accuracy 0.9
step 900, training accuracy 1
test accuracy 0.9648

我想我会尝试从源代码重新安装“所有内容”的较新版本。

最佳答案

安装更新版本的 CUDA 和 CuDNN 似乎已经解决了该问题。 (我看到 CuDNN 的下载页面明确指出版本 4 不适用于 GTX 1070/1080。)

对我有用的是:

  • 使用“图形驱动程序团队”Ubuntu PPA 来安装 nvidia-367 驱动程序。
  • 使用运行文件安装 CUDA 8.0RC,未安装捆绑的驱动程序。我尝试了 deb 文件,但在安装捆绑的 nvidia-361 驱动程序时遇到了一些问题。我从未尝试过第三个选项(某些 tar.gz 文件 IIRC?)
  • 从源代码安装了 bazel,由于对 java 的某些依赖,我再次在自定义 apt 存储库中遇到了一些问题。
  • 我使用了来自tensorflows git repo的HEAD,没有特殊原因。
  • 我遇到了this issue (或非常相似的东西)。通过切换到 gcc-4.9 而不是默认值解决了这个问题。 (我只更改了 tensorflow 配置脚本中的路径。)我不知道为什么会这样,这只是一个幸运的猜测。
  • 由于缺少头文件,我认为我需要安装 zlib1g-dev 软件包,但如果是这样,错误消息非常清楚,这就是问题所在。

关于tensorflow - 使用 Pascal GPU 的 "Deep MNIST for Experts"精度极低,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38036837/

相关文章:

python - 如何解释 model.evaluate() 返回的损失?

python - tensorflow 如何从元恢复图形并将其放置在不同的设备上

python - 为什么 TensorFlow 会提示我将错误的形状和类型输入到占位符中?

python-3.x - 如何修复 "There is at least 1 reference to internal data in the interpreter in the form of a numpy array or slice"并在 tf.lite 上运行推理

python - train_on_batch() 在 keras 模型中做了什么?

numpy - 使用 Conv2d 进行图像调整

python-3.x - 我的简单损失函数导致 NAN

python - 在 resnet 模型中拟合图像时出现尺寸问题

python - 检查节点是 Tensorflow Graph 中的操作还是张量

tensorflow - 您必须为 MNIST 数据集的 dtype float 和 shape [?,784] 提供占位符张量 'Placeholder' 的值