Environment Configuration
The system can run version
- Ubunte version 16.04 or higher
- Windows 7 or later
- Version of Mac OS 10.12.6 (Sierra) or higher
- Raspbian 9.0 or later
Installation and configuration software environment
Here anaconda is not recommended, because of copyright issues anaconda, mirroring the source of most of the country is no longer updated, only Tsinghua source to obtain the authorization, but does not determine the future will not be stopped for other reasons, so here recommended direct use of Python virtual environment to learn and use tensorflow
Python version and scientific computing modules used to
- pyenv
- python 3.6.8
- numpy
- pandas
- matplotlib
- jupyter notebook
- scikit-learn
- tensorflow
Pyenv installation and basic use
Pyenv Python is a multi-version management tool to help us in no interval interchangeable daily development of multiple versions, to facilitate our development work, while isolating the Python environment, avoiding version conflicts package
Pyenv installation
由于pyenv使依赖于git的,因此我们需要先安装git
yum -y install git
然后使用curl来安装pyenv,pyenv其实就是一个shell脚本有兴趣的可以看下
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
安装完成后会提示配置环境变量
vim ~/.bash_profile
追加下面的内容
export PATH="~/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
The basic use of Pyenv
安装Python需要的依赖关系
yum -y install gcc make patch
yum -y install gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-devel ca-certificates
安装Python
pyenv install 3.6.8
设置当前目录的Python环境
pyenv local 3.6.8
设置Python全局环境
pyenv global 3.6.8
注意:如果可以的话永远不要使用这个命令,因为当使用了global命令的话,就将其项目的python版本也都修改成global设置的版本了,这样就会出现很大的纰漏
若是错误使用了global,则只需要删除version文件即可,但是千万注意,一定不要删除了其他的文件
Pyenv virtual environment
Some time will use the same python version on multiple projects, or if using the above method, then there will be mistakes, but also just revised version of python perform operations in the current directory, so you need to use here python virtual environment
In fact, plainly create a python version of the virtual environment is to copy a version information
创建虚拟环境
pyenv virtualenv 3.6.8 tensorflow
执行pyenv versions查看python版本时候,会返回下面的结果:
* system (set by /root/.pyenv/version)
3.6.8
3.6.8/envs/tensorflow
tensorflow
这个时候我们会发现多了两个python的版本,在这里说明下,那个单独的tensorflow的
版本就是为了方便我们的使用,其实tensorflow这个版本可以说是一个别名,链接到
3.6.8/envs/tensorflow这个版本的
下面我们就使用lcoal方法使用tensorflow这个别名对应的版本吧
pyenv local lanyulei
当我们不用这个虚拟环境了,想删除那么执行下面的命令即可
pyenv uninstall lanyulei
虚拟环境目的是在于隔离,隔离第三方包
因为每个项目可能依赖相同的第三方包,但是版本不同因此需要隔离
Scientific computing module used to install
Here bean source directly mounted pip
Install the CPU version of tensorflow
pip install numpy pandas matplotlib notebook scikit-learn tensorflow==2.0.0 -i https://pypi.douban.com/simple
GPU installed version of tensorflow
pip install numpy pandas matplotlib notebook scikit-learn tensorflow-gpu==2.0.0 -i https://pypi.douban.com/simple
If you are using tensorflow GPU, then, you need to install the software NAIDIA
自行百度安装吧
CUDA toolkit
tensorflow 支持 CUDA 10.0
cuDNN SDK
7.4.1及更高的版本,用于深度神经网络的GPU加速原语库
Check that the installation was successful tensorflow
In [1]: import tensorflow as tf
In [2]: tf.__version__
Out[2]: '2.0.0'
Print tensorflow version number, because we are installing a tensorflow 2.0, so the output of 2.0.0, means that we have successfully installed