1.安装Anaconda
下载 Anaconda2-5.0.1-Linux-x86_64.sh 文件
执行下面命令:
bash Anaconda2-5.0.1-Linux-x86_64.sh
遇到选yes或no的都选yes
具体参考此博客:https://blog.csdn.net/woainishifu/article/details/74978647
2.安装Tensorflow
调用以下命令创建名为 tensorflow 的 conda 环境,以运行某个版本的 Python:
conda create -n tensorflow pip python=2.7
激活tensorflow环境:
source activate tensorflow
安装python2.7 仅支持CPU的tensorflow
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.6.0-cp27-none-linux_x86_64.whl
python3.6 GPU版本,更多版本查看https://www.cnblogs.com/hezhiyao/p/8330435.html
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.4.1-cp36-cp36m-linux_x86_64.whl
3.测试
输入以下几行代码:
python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
输出结果为Hello, TensorFlow! 说明安装成功
4.退出tensorflow环境:
source deactivate
5.问题
1)在ipython和jupyter notebook中,import tensorflow时,都显示找不到模块
目前的解决方案:在tensorflow环境下再安装一遍这两个文件
conda install jupyter
我的疑惑:如何不通过载安装的方式解决这个问题,比如通过改什么路径的方式
问题原因:网速太慢,下载失败
解决方案:用清华大学开元软件镜像站
在tensorflow环境下,运行以下命令,即可成功安装jupyter:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --set show_channel_urls yes
Conda包管理
# 安装xxxx conda install xxxx # 查看当前环境下已安装的包 conda list # 查看某个指定环境的已安装包 conda list -n python34 # 查找package信息 conda search numpy # 安装package # 如果不用-n指定环境名称,则被安装在当前活跃环境 也可以通过-c指定通过某个channel安装 conda install -n python34 numpy
Conda 更新
# 更新python34环境下的numpy conda update -n python34 numpy # 删除python34环境下的numpy conda remove -n python34 numpy
安装scikit-learn,报错
conda install -c anaconda scikit-learn
sudo apt install python3-sklearn
参考博客:https://blog.csdn.net/guan__hua/article/details/61240932