搭建搭建TensorFlow((CPU版本)环境版本)环境
1、在官网下载Anaconda,并安装(按照提示安装即可);
2、安装好Anaconda之后,在开始菜单中的所有程序中找到Anaconda文件夹,点击其中的Anaconda Prompt;
3、在出现的界面中,配置镜像源:
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
4、conda env list 查看安装了哪些虚拟环境(一般只有一个base);
5、conda create -n tf python=3.6.5 创建一个名字为tf的虚拟环境,python的版本为3.6.5;
6、activate tf 激活tf虚拟环境(前面的base变成tf)
7、conda install tensorflow==2.1.0(pip install tensorflow==2.1.0 用pip表示从官网下载,而conda表示是从镜像源下载,从镜像源下载
速度要快,另外tensorfl2.1版本不区分GPU和CPU,如果想安装其它版本的tensorflow环境,只需要改后面的版本号)
8、在tf中虚拟环境中,python+回车,进入python环境中,(1)import tensorflow as tf (2)print(tf.__version__),如果出现
tensorflow的版本号,就说明环境安装完成。
注:安装好tensorflow环境后,使用jupyter notebook时,有时会出现配置的环境不能用(import tensorflow as tf 时会报错:显
示没有此模块),使用下面步骤解决问题:
1、激活虚拟环境
activate tf
2、安装nb_conda
conda install nb_conda
3、运行jupyter notebook
`jupyter notebook`
4、在jupyter首页的NEW下拉框中就出现了Python [conda env:tf],这样就可以使用安装的tensorflow环境了。
作者:言不知所起
评论0
最新资源