win10+anaconda环境下tensorflow和pytorch的cpu版安装

win10+anaconda环境下tensorflow和pytorch的cpu版安装

anaconda3 5.1.0+python3.6+tensorflow1.4

1.管理员身份运行cmd(确保anaconda的scrip文件有添加到环境变量中)

#创建一个新的虚拟环境
#conda env list 或 conda info -e 可查看当前存在哪些虚拟环境
conda create -n tensorbase python=3.6
activate tensorbase

2.更换为清华的源(可能需要更新pip,按照错误提示中推荐的代码更新就好)

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple #

3.安装tensorflow1.4

#gpu版
# https://developer.nvidia.com/cuda-gpus查看电脑显卡,是否支持gpu
#pip install tensorflow -gpu
#cpu版
pip install tensorflow==1.4 

4.检查是否装好

python
import tensorflow as tf( 可能会有warning )
w=tf.Variable(0,dtype=tf.float32)
quit()

5.安装jupyter notebook

conda install ipython  (要在tensorbase环境下)
conda install jupyter 
ipython kernelspec install-self --user
jupyter notebook
#打开后 import tensorflow试试(有warning没关系)
#退出环境:deactivate tensorbase

pytorch1.5.1安装

1.创建环境pt,使用python版本为3.6,并配置国内源

conda create -n pt python=3.6
#激活环境:activate pt
#配置国内源,方便安装Numpy,Matplotlib等
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/
#配置国内源,安装pytorch用
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

2.在官网上生成适合自己电脑的pytorch安装代码
我的显卡没法安装cuda,故下载的cpu版本,
注意:网站上复制下来的代码指定的是从国外库中拉出pytorch文件,故在国内安装时记得把-c pytorch这个参数去掉

conda install pytorch torchvision cpuonly 

3.安装常用库

pip install numpy matplotlib pillow pandas

4.查看是否安装成功:

python
import torch

NVIDIA显卡选择

安装GPU版的要先下载CUDA,而CUDA只能运行在NVIDIA显卡上,查看电脑显卡 ,看是否支持gpu。若要购买显卡,预算不太够的情况下推荐GTX1050 Ti,显存容量4GB,能运行少量网络结构,作为入门学习足够了,预算充足情况下可考虑GTX 1080 Ti。害,可我是真滴穷,后面搬砖攒够钱了再换吧,先学着,加油加油~

猜你喜欢

转载自blog.csdn.net/hcjdgskg/article/details/106922071