小白一个,记录一下自己学习过程中遇到的问题以及解决方法。
前提是已经有anaconda和jupyter,这里只阐述如何在这里面添加新的环境
目的:在已有的 Jupyter Notebook 界面中添加新的虚拟环境(如 jup
)作为可选内核,避免重复安装 Jupyter
1. 打开 Anaconda Prompt(或终端)
2. 创建环境并激活
①创建为 jup
的新环境(使用 Python 3.10)
conda create -n jup python=3.10
②激活环境
conda activate jup
3. 安装 GPU版本的PyTorch (CUDA 11.7)
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
4. 安装ipykernel
conda install ipykerne
5. 将当前环境注册到 Jupyter
# --display-name 自定义 Jupyter 界面中的内核名称
python -m ipykernel install --user --name jup --display-name "Python (jup)"
注:在添加环境的过程中遇到另一种方法(如下),这个会浪费磁盘空间,而且不同环境的jupyter可能因依赖包版本不同导致冲突
# 在环境中安装独立 Jupyter 实例,与全局 Jupyter 隔离
conda install jupyter -c conda-forge