windows安装TF

查看本机python和pip的版本

python --version
pip --version

我这例python为3.6 pip为21

1创建虚拟环境

先自己找好一个盘,比如我选的E盘
控制台

e:
python -m venv --system-site-packages .\venv

激活虚拟环境

.\venv\Scripts\activate

更新

e:\venv\Scripts\python.exe -m pip install --upgrade pip

pip list  # show packages installed within the virtual environment

关闭虚拟环境

deactivate  # don't exit until you're done using TensorFlow

安装tf

Choose one of the following TensorFlow packages to install from PyPI:

tensorflow —Latest stable release with CPU and GPU support (Ubuntu and Windows).
tf-nightly —Preview build (unstable). Ubuntu and Windows include GPU support.
tensorflow==1.15 —The final version of TensorFlow 1.x.

pip install --upgrade tensorflow-gpu

或者

pip install --upgrade tensorflow-cpu
pip install tensorflow==1.15      # CPU
pip install tensorflow-gpu==1.15  # GPU

验证

python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
posted @ 2021-02-24 15:38  cyssmile  阅读(119)  评论(0编辑  收藏  举报