天天看点

Ubuntu下Tensorflow安装遇到的问题

Tensorflow安装

tensorflow安装官网:https://www.tensorflow.org/versions/r1.0/install/install_linux

由于我是以普通用户登录进Ubuntu桌面系统,因此在完全采用官网anaconda方式安装的过程中遇到了一些问题,在这里记录下来。

官网中采用anaconda方式安装tensorflow的流程:

1.Follow the instructions on the Anaconda download site to download and install Anaconda.

2.Create a conda environment named tensorflow to run a version of Python by invoking the following command:

$ conda create -n tensorflow
           

3.Activate the conda environment by issuing the following command:

$ source activate tensorflow
 (tensorflow)$  # Your prompt should change 
           

4.Issue a command of the following format to install TensorFlow inside your conda environment:

由于我的Python是2.7版本,且安装的是Tensorflow的GPU版,因此TF_PYTHON_URL的值为:

在这一步中遇到了问题:由于我是普通用户,因此执行上面第四步命令pip install ……是没有权限的,后来,我采用sudo pip install …….,发现安装完成了,没有提示错误,可奇怪的是在Python环境下始终导入不了tensorflow,即在Python 环境下”import tensorflow as tf”会提示找不到tensorflow模块。我便重启了电脑,在终端下输入:

发现没有tensorflow模块,说明没有安装成功。

原因:

后来在网上查找原因,发现pip install…….和sudo pip install……,其安装的位置是不一样的。没办法,那就只能采用pip install……的方式安装。在安装过程中,会出现各种权限”Permission denied”的问题,如下图所示:

Ubuntu下Tensorflow安装遇到的问题
Ubuntu下Tensorflow安装遇到的问题

解决办法:

对出现问题的文件,用如下命令:

sudo chown -R $USER 后面加上指定的文件
           

改变其所属的用户组,以及用如下命令:

sudo chmod  后面制定的文件
           

改变其文件权限,然后再重新执行上述的第四步。这样就可安装成功。

Ubuntu下Tensorflow安装遇到的问题

继续阅读