3

好吧,我认为八小时足以自己解决这个问题,所以我会问人们:

我在 jupyterhub 和 Jupyter notebook 之外的名为“tensorflow”的虚拟环境中运行 tensorflow-gpu 1.1.0 就好了。也就是说,我可以使用 gpu 导入 tensorflow 并使用它运行脚本。

当我在我的 tensorflow virtualenv 中并使用 jupyterhub 时,Jupyter 似乎无法“看到”张量流。我收到以下错误:

ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory

1)这是一个常见的错误消息,表明 tensorflow 安装问题,但我的路径和环境变量似乎很好。毕竟,我可以在 Jupyter 之外很好地使用 tensorflow-gpu。

2)键入“which jupyter”显示~/anaconda3/envs/hub/bin/jupyter,所以我相信我在我的 virtualenv 中引用了 jupyter。3)Pip freeze表明我有 jupyterhub 和 tensorflow-gpu。我什至做了一个pip3 freeze,它也显示了两个包。

有任何想法吗?tensorflow-gpu 可以从 Jupyter 笔记本上运行吗?

4

1 回答 1

4

我从这里得到了解决方案:

[ https://github.com/jupyter/notebook/issues/1290][1]

基本上,jupyter 出了点问题,因为它无法读取我的LD_LIBRARY_PATH变量。我确实将所有内容正确放入 .bashrc 中,所以我不知道为什么。

切换到命令行(终端)。如果您有虚拟环境,请切换到您的虚拟环境。

输入: jupyter notebook --generate-config

它将告诉您存储 jupyter 配置文件的目录。如果要再次列出它,请键入: jupyter --config-dir

我的 jupyter_notebook_config.py 文件位于此处: /home/me/.jupyter/jupyter_notebook_config.py

在此文件的最顶部jupyter_notebook_config.py,添加以下代码:

import os
c = get_config()
os.environ['LD_LIBRARY_PATH'] = '/usr/local/cuda-8.0/lib64:usr/local/cuda-8.0/lib64/libcudart.so.8.0'
c.Spawner.env.update('LD_LIBRARY_PATH')

然后重启 jupyterhub 或 jupyter notebook(在命令行输入:jupyter notebook

TensorFlow gpu 应该可以工作。

即使您正在运行 jupyterhub,同样的事情也适用。在 jupyter 而不是 jupyterhub 中进行更改。(jupyterhub 的每个用户都有自己的 jupyter 进程,因此不要在“hub”级别进行更改,而是在 jupyter notebook 级别进行更改。

于 2017-05-17T06:15:58.980 回答