我已經使用anaconda環境安裝tensorflow,如tensorflow website中所述,並且在更改我的python安裝路徑之後。如何從Conda在Jupyter Notebook中導入TensorFlow並支持GPU?
[email protected]:~$ which python
/home/dennis/anaconda2/bin/python
Jupyter已安裝。我認爲,如果我能夠在conda環境中導入和使用tensorflow,我將能夠在Jupyter中執行相同的操作。但是,情況並非如此 -
在我的系統導入tensorflow(未激活環境)
[email protected]:~$ python
Python 2.7.11 |Anaconda 4.1.0 (64-bit)| (default, Jun 15 2016, 15:21:30)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tensorflow
>>> exit()
導入tensorflow在暢達環境
[email protected]:~$ source activate tensorflow
prepending /home/dennis/anaconda2/envs/tensorflow/bin to PATH
(tensorflow) [email protected]:~$ python
Python 2.7.12 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:42:40)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import tensorflow as tf
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:102] Couldn't open CUDA library libcudnn.so. LD_LIBRARY_PATH: /usr/local/cuda-7.5/lib64
I tensorflow/stream_executor/cuda/cuda_dnn.cc:2092] Unable to load cuDNN DSO
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
正如上面的導入是成功我試圖做同樣的jupyter (在環境內啓動jupyter)但我得到了以下錯誤導入 -
ImportError Traceback (most recent call last)
<ipython-input-1-41389fad42b5> in <module>()
----> 1 import tensorflow as tf
ImportError: No module named tensorflow
我的猜測是筆記本電腦沒有在conda環境中運行。那麼,你能告訴我,我該如何強迫它做同樣的事情?
或者,你可以爲我提供有關如何導入tensorflow在jupyter
編輯#1細節:
我已成功安裝tensorflow使用conda install -c jjhelmus tensorflow=0.9.0
命令Anaconda安裝。 [來源:conda.anaconda.org/jjhelmus]
但這禁用GPU的支持,所以代碼類似下面的返回一個錯誤
with tf.Session() as sess:
with tf.device("/gpu:0"): #GPUs are not enabled on the system so it throws an error
matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])
product = tf.matmul(matrix1, matrix2)
result = sess.run([product])
print result
那麼,我該如何啓用GPU支持?有支持GPU的conda安裝tensorflow的替代解決方案嗎?
編輯#2:
它提到here,只有當源是建立目標GPU是GPU的支持是可能的。 如果這是真的,請提供關於如何完成的詳細信息,以便我可以安裝GPU啓用tensorflow。
你在哪個平臺上?如果你在linux上,谷歌現在已經制作了一個預製的二進制文件,你可以很容易地使用anaconda。 https://www.tensorflow.org/versions/r0.9/get_started/os_setup.html#anaconda-installation – user2561747