本人计算机配置:
Anaconda3-5.2.5,cuda10.0.130_410.48,cudnn-10.0,opencv3
前提:
1)Anaconda安装
安装了GPU版本的Anaconda(同时,jupyter notebook安装完毕)
2)创建虚拟环境条件
首先,配置清华镜像(原始镜像下载慢),使之后下载更快捷。方法如下:
conda config --add channels https://mirrors.tuna./anaconda/pkgs/free/conda config --set show_channel_urlsyes
镜像改变完成。若是windows系统,在C盘Users文件夹下的.condarc文件做如下更改:
删除-defaults。
3)创建虚拟环境
conda create -n tfpy python=3.6
创建了一个python=3.6版本环境名字为tfpy的虚拟环境,tfpy自己定义的环境名。
在此虚拟环境tfpy下安装tensorflow,步骤如下:
1)激活tfpy环境conda activate tfpy2)查看此环境下,可支持安装的tensorflow版本conda search --full -name tensorflow3)安装选定版本的tensorflow之前,将pip更新到最新版pip install --upgrade pip4)安装tensorflowpip install tensorflow-gpu==1.9.0(cpu版:tensorflow;gpu版:tensorflow-gpu)或者pip install tensorflow-gpu==1.11.0 -ihttps://pypi.tuna./simple5)验证是否安装成功,在此环境下进行如下操作pythonimport tensorflow as tfprint(tf.__version__)print(tf._path_)
4)下面是一些关于虚拟环境的操作
删除虚拟环境:
conda remove -n your_env_name --all
查看安装了哪些包:
conda list
安装缺少的包:
conda install package_name
查看当前存在哪些虚拟环境:
conda env list或conda info -e
检查更新当前conda:
conda update conda
关闭激活环境:
conda deactivate tfpy
关于jupyter操作:
1)添加kernel
方法一:安装ipykernel:pip install ipykernel通过ipykernel为jupyter添加新环境:python -m ipykernel install --name tfpy查看jupyter中kernel:jupyter kernelspec list方法二:创建环境时直接创建对应ipykernelConda create -n tensorflow-g27 python=3.5 ipykernel
遇到问题:
1)安装tensorflow-gpu==1.14.0时,报错
ERROR: tensorboard 1.14.0 has requirement setuptools>=41.0.0, but you'll have setuptools 36.4.0 which is incompatible.
原因:此环境下setuptools版本太低
解决:更新setuptools版本
pip install --upgrade setuptools