一、tensorflow环境配置教程
step 1:查看tensorflow\keras\python对应版本
step 2、创建虚拟环境:
# 创建虚拟环境
conda create -n 'my_env' python=3.7
# 删除虚拟环境
conda remove -n 'you_env_name' --all
# 删除虚拟环境中包
conda remove --name 'you_env_name' 'you_package_name'
step 3、激活环境:
conda activate my_env
step 4、如电脑有gpu,则键入:如没有则跳过
conda install cudatoolkit=10.1
step 5、如电脑有gpu,则键入:如没有则跳过
conda install cudnn=7.6
step 6、安装tensorflow
pip install tensorflow==2.1
step 7、验证是否安装成功:
python
import tensorflow as tf
tf.__version__
二、虚拟环境内核加入kernel
step 1:进入虚拟环境
activate my_env
step 2:在虚拟环境中安装ipython
conda install ipykernel
step 3:添加虚拟环境的python kernel:
python -m ipykernel install --name my_env
其他相关语句:
# 查看kernel列表
jupyter kernelspec list
# 删除指定kernel
jupyter kernelspec remove 'your_kernel_name'
三、jupyter安装插件,实现代码提示等功能
step 1:安装jupyter_contrib_nbextensions扩展工具
pip install jupyter_contrib_nbextensions -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/
jupyter contrib nbextension install --user
step 2:安装jupyter_nbextensions_configurator扩展工具
pip install jupyter_nbextensions_configurator -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/
jupyter nbextensions_configurator enable --user
step 3:重启notebook,勾选对应栏目,实现配置
安装成功后,会在http://localhost:8888/tree中出现Nbextensions;勾选Codefolding、Hinterland等实现配置。
四、jupyter notebook背景主题、字体大小设置
step 1:安装jupyter主题:
pip install jupyterthemes -i https://mirrors.aliyun.com/pypi/simple
step 2:更新jupyter主题
pip install --upgrade jupyterthemes
step 3:查看可用主题
jt -l
step 4:设置主题
jt -t monokai -f fira -fs 13 -cellw 90% -ofs 11 -dfs 11 -T -N
# -f(字体) -fs(字体大小) -cellw(占屏比或宽度) -ofs(输出段的字号) -T(显示工具栏) -N(显示自己主机名)
step 5:恢复默认主题
jt -r