在 ubuntu 的 gpu 上安装 tensorflow
Posted
技术标签:
【中文标题】在 ubuntu 的 gpu 上安装 tensorflow【英文标题】:tensorflow installation on gpu in ubuntu 【发布时间】:2019-01-03 21:47:58 【问题描述】:pip3 安装 tensorflow-gpu --user
每当我运行上述命令时,我通常都会收到此消息;
Requirement already satisfied: tensorflow-gpu in ./.local/lib/python3.5/site-packages (1.9.0)
Requirement already satisfied: setuptools<=39.1.0 in ./.local/lib/python3.5/site-packages (from tensorflow-gpu) (39.1.0)
Requirement already satisfied: protobuf>=3.4.0 in ./.local/lib/python3.5/site-packages (from tensorflow-gpu) (3.6.0)
Requirement already satisfied: absl-py>=0.1.6 in ./.local/lib/python3.5/site-packages (from tensorflow-gpu) (0.3.0)
Requirement already satisfied: wheel>=0.26 in ./.local/lib/python3.5/site-packages (from tensorflow-gpu) (0.31.1)
Requirement already satisfied: numpy>=1.13.3 in ./.local/lib/python3.5/site-packages (from tensorflow-gpu) (1.15.0)
Requirement already satisfied: termcolor>=1.1.0 in ./.local/lib/python3.5/site-packages (from tensorflow-gpu) (1.1.0)
Requirement already satisfied: six>=1.10.0 in ./.local/lib/python3.5/site-packages (from tensorflow-gpu) (1.11.0)
Requirement already satisfied: gast>=0.2.0 in ./.local/lib/python3.5/site-packages (from tensorflow-gpu) (0.2.0)
Requirement already satisfied: tensorboard<1.10.0,>=1.9.0 in ./.local/lib/python3.5/site-packages (from tensorflow-gpu) (1.9.0)
Requirement already satisfied: grpcio>=1.8.6 in ./.local/lib/python3.5/site-packages (from tensorflow-gpu) (1.13.0)
Requirement already satisfied: astor>=0.6.0 in ./.local/lib/python3.5/site-packages (from tensorflow-gpu) (0.7.1)
Requirement already satisfied: werkzeug>=0.11.10 in ./.local/lib/python3.5/site-packages (from tensorboard<1.10.0,>=1.9.0->tensorflow-gpu) (0.14.1)
Requirement already satisfied: markdown>=2.6.8 in ./.local/lib/python3.5/site-packages (from tensorboard<1.10.0,>=1.9.0->tensorflow-gpu) (2.6.11)
当我转到 python3 并将 tensorflow 导入为 tf; 我收到以下错误:
ImportError: libcublas.so.9.0: 无法打开共享对象文件:没有这样的文件或目录
【问题讨论】:
您是否遵循完整的 tensorflow 安装说明?首先安装 CUDA/CUDNN 并确保使用 cuda 库的位置更新 LD_LIBRARY_PATH 环境变量。 是的,这是我的 cuda env 路径。导出 PATH=/usr/local/cuda-9.2/bin$PATH:+:$PATH 导出 LD_LIBRARY_PATH=/usr/local/cuda-9.2/lib64$LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH跨度> 使用 cuda 9.0。预编译的 tensorflow 查找 9.0。如果要使用 9.2,请从源代码构建 tensorflow。还运行“env”命令以确保您有正确的路径组件,用“:”分隔 感谢您的评论:我已经回应了 $LD_LIBRARY_PATH,它给了我这个信息:/usr/local/cuda-9.2/lib64:/opt/intel/compilers_and_libraries_2018.3.222/linux/tbb /lib/intel64_lin/gcc4.7:/opt/intel/compilers_and_libraries_2018.3.222/linux/compiler/lib/intel64_lin:/opt/intel/compilers_and_libraries_2018.3.222/linux/mkl/lib/intel64_lin pip3 show tensorflow 名称:tensorflow 版本:1.9.0 总结:TensorFlow 是一个适合所有人的开源机器学习框架。主页:tensorflow.org 作者:Google Inc. 作者电子邮件:opensource@google.com 许可证:Apache 2.0 位置:/home/asad.ullah/.local/lib/python3.5/site-packages 要求:protobuf, gast, tensorboard, termcolor, grpcio, absl-py, setuptools, wheel, numpy, Six, astor 要求: 【参考方案1】:我遇到了确切的问题。我卸载了 tensorflow 并按照下面链接中提到的步骤进行操作,它起作用了: http://www.python36.com/how-to-install-tensorflow-gpu-with-cuda-9-2-for-python-on-ubuntu/
【讨论】:
感谢您的回答,是否可以在没有root或sudo的情况下安装TF? 是的。这是可能的。但是,我不确定您的程序的结果。您可能会遇到一些与 CUDA 或其他相关的访问问题。如果您发现我的回答很有用并且解决了您的问题,请接受并投票。 对于 9.1 cuda,您可以直接编译 tensorflow,而无需使用以下命令制作 bazel 源: conda install -c anaconda tensorflow-gpu以上是关于在 ubuntu 的 gpu 上安装 tensorflow的主要内容,如果未能解决你的问题,请参考以下文章
在 Ubuntu 上安装 Tensorflow GPU / CUDA
在Ubuntu 17.10(GPU)上安装Pytorch的问题