深度学习环境配置:Windows安装TensorFlow并在Jupyter notebook上使用

前言

深度学习环境配置:Windows安装TensorFlow并在Jupyter notebook上使用

01. 安装Anaconda

## 1.1 国内镜像源配置

  1. 清华镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pbkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  1. 中科大镜像源(小编选择这个)
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
  1. 切回默认源
    注意,如果切换镜像后当出现下载不了的情况,就先切换默认源,然后再修改另一个可以使用的conda源(一定要先恢复默认,再换另一个!!!),也可以使用其他镜像网站
conda config --remove-key channels
  1. 查看当前用的源
conda config --show channels 

## 1.2 为tensorflow创建虚拟环境例子:本来想用这样的配置方式,但是jupyter一直连接不上,pycharm、ipython却没有问题。

conda create -n tf1.15 python=3.6
  • 激活TensorFlow环境
conda activate tf1.15
  • 在虚拟环境中安装tensorflow
conda/pip install tensorflow==2.6.0
conda/pip install tensorflow-gpu==2.6.0 
conda/pip install --upgrade tensorflow #会更新到2.x
# conda install ipykernel
# conda install jupyter
conda install jupyter notebook
  • 安装特定虚拟环境的内核

python -m ipykernel install --user --name myenv --display-name "myenv"
python -m ipykernel install --user --name tf1.15 --display-name "tf1.15"
ipython kernel install --user --name tf1.15 --display-name tf1.15

ipython kernel install --user --name kr243 --display-name kr243 

ipython kernel install --user --name tensorflow --display-name tensorflow 
ipython kernelspec install-self --user

jupyter kernelspec install-self --user 

# 查看内核安装位置
# jupyter kernelspec list
  • 删除虚拟环境
conda remove -n tensorflow --all

# 02. 安装tensorflow

  • 上述的## 1.2 为tensorflow创建虚拟环境例子 配置完成后,jupyter不能完美工作,于是有了这部分。
  • 此处推荐参考文章:深度学习环境配置:tensorflow-gpu + keras,和参考视频https://www.bilibili.com/video/BV1HV411q7xD,很好的阐释了各版本如何匹配选择。
  • 小编使用的是Python 3.9.7,所以需要选择tensorflow-2.6.0,选择对照表如下:
  • 在这里插入图片描述
  • 打开命令提示符进行下面安装,注意,小编用的就是这个,而没有选择虚拟环境在这里插入图片描述
pip install tensorflow==2.6.0
pip install tensorflow-gpu==2.6.0

# 03. 配置jupyter notebook默认工作目录

其他参考文章:

后记

  • 肯定不是完美的教程,此处记录,只是为了自己后期查阅。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

杰之行

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值