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

人工智能77

前言

深度学习环境配置: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

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

  • 删除虚拟环境
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,选择对照表如下:
  • 打开 命令提示符进行下面安装,注意,小编用的就是这个,而没有选择虚拟环境深度学习环境配置:Windows安装TensorFlow并在Jupyter notebook上使用
pip install tensorflow==2.6.0
pip install tensorflow-gpu==2.6.0

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

其他参考文章:

后记

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

Original: https://blog.csdn.net/haojie_duan/article/details/122120406
Author: 杰之行
Title: 深度学习环境配置:Windows安装TensorFlow并在Jupyter notebook上使用