Tensorflow未在Jupyter

Tensorflow未在Jupyter

本文介绍了Tensorflow未在Jupyter Notebook中的GPU上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为Ubuntu上的GTX 1080 ti成功安装了Cuda和cudnn,在jupyter笔记本中运行一个简单的TF程序,在运行tensorflow-gpu == 1.0 vs tensorflow == 1.0的conda环境中,速度没有增加.

Installed Cuda and cudnn sucessfully for the GTX 1080 ti on Ubuntu, running a simple TF program in the jupyter notebook the speed does not increase in a conda environment running tensorflow-gpu==1.0 vs tensorflow==1.0.

当我运行nvidia-smi时:

When I run nvidia-smi :

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 375.66 Driver Version: 375.66 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 108... Off | 0000:01:00.0 On | N/A |
| 24% 45C P0 62W / 250W | 537MiB / 11171MiB | 0% Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 1101 G /usr/lib/xorg/Xorg 310MiB |
| 0 1877 G compiz 219MiB |
| 0 3184 G /usr/lib/firefox/firefox 5MiB |
+-----------------------------------------------------------------------------+

我尝试将"with tf.device("/gpu:0"):"放在矩阵乘法的前面,但这只是给我一个错误:

I have tried putting the "with tf.device("/gpu:0"):" in front of the matrix multiplications but it just gives me an error:

"InvalidArgumentError(请参见上面的回溯):无法将设备分配给节点'MatMul':无法满足显式设备规范'/device:GPU:0',因为在此过程中未注册与该规范匹配的设备;可用设备:/job:localhost/副本:0/任务:0/cpu:0[[节点:MatMul = MatMul [T = DT_FLOAT,transpose_a = false,transpose_b = false,_device ="/device:GPU:0"](重塑,softmax/变量/读取)]]"

"InvalidArgumentError (see above for traceback): Cannot assign a device to node 'MatMul': Could not satisfy explicit device specification '/device:GPU:0' because no devices matching that specification are registered in this process; available devices: /job:localhost/replica:0/task:0/cpu:0[[Node: MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/device:GPU:0"](Reshape, softmax/Variable/read)]]"

我知道cudnn已正确安装,因为在终端中运行该消息时会收到此消息.

I know cudnn is installed correctly because I get this message when running it in the terminal.

import tensorflow as tf
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

我认为这与Jupiter笔记本电脑有关,是否存在兼容性问题?当我运行TF会话时,我得到以下输出:

I think this has to be something with the Jupiter notebook, is there a compatibility issue? When I run the TF session I get this output:

W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
Device mapping: no known devices.

""

推荐答案

我解决了这个问题.显然我在环境之外安装了jupyter和常规的tensorflow.但是我在我的环境中安装了tensorflow-gpu.因此,当我运行jupyter时,它是在环境外部调用tensorflow,而不是在环境内部安装tensorflow-gpu.

I solved the issue. Apparently I had jupyter and regular tensorflow installed outside of my environment. Yet I had tensorflow-gpu installed within my environment. So when I ran jupyter it was calling the tensorflow outside of the environment not the tensorflow-gpu installed within the environment.

这篇关于Tensorflow未在Jupyter Notebook中的GPU上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 09:57