1、激活环境
以下所有命令都在Anaconda Prompt中操作。
bash
conda activate 环境名称
我的环境名称是myenv
如果不知道自己的pytorch配在哪个环境,就用下面方法挨个试。
2、安装jupyter
1、安装
bash
pip install jupyter

2、如果已经安装,检查jupyter是否已经安装在此环境中
bash
conda list 想要检查的包的名称

3、安装ipykernel
bash
pip install ipykernel -i https://pypi.tuna.tsinghua.edu.cn/simple

4、将torch环境加入jupyter内核
bash
python -m ipykernel install --name 环境名称

5、修改juypter默认运行环境
1、先新建一个空白文件夹,文件夹名称自己起(我这里叫jupyterFiles)
2、查看jupyter配置文件地址
bash
jupyter notebook --generate-config
根据文件生成路径找到generate-config文件,并打开
3、在已经打开的文件中,使用快捷键ctrl+f 搜索 The directory to use for notebooks。大概是984行上下,去除注释并添加你新建的文件夹地址。如下图
(这个图里的路径不是我的路径,我应该写成E:\DeepLearning\jupyterFiles)
6、运行jupyter
bash
jupyter notebook

7、点击new 选择你的torch环境

测试
bash
import torch
print(torch.cuda.is_available())
