安装tf2的cpu运行版本使用pip安装几个包即可,但是tf2-gpu需要一定的cuda等环境,所以这里使用anaconda来安装tf2-gpu的虚拟环境,简化安装过程。
安装anaconda
下载Anaconda3-5.0.1-Linux-x86_64.sh,下载地址为: https://repo.continuum.io/archive/index.html,需要将anaconda加入到环境变量中。
启动环境
- source ~/.bashrc安装后重启环境变量
- 输入anaconda -V之后会输出anaconda Command line client
创建环境
- conda create -n tf2 python=3.6 创建一个环境,用来安装tensorflow2.0以及相关的python packages.
- tf2的配置目录是在anaconda3-envs,运行source activate tf2激活环境
- conda install cudatoolkit=10 cudnn=7.3
- conda install tensorflow-gpu
- pip install tf-nightly-gpu
- pip install tf-nightly-gpu-2.0-preview
- pip install --upgrade tensorflow-gpu==2.0.0-beta1
安装jupyter
- pip install jupyter notebook
- nohup jupyter notebook & 运行jupyter服务