Jupyter notebook 配置 conda

本文详细介绍了如何配置conda环境,包括下载conda、添加源、配置环境变量,以及安装和管理Jupyter Notebook。通过创建新环境、查看CUDA和CUDNN版本,到生成并修改Jupyter Notebook的配置文件,启动服务并安装扩展插件,为新手提供了全面的教程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下载conda

https://www.anaconda.com/distribution/

安装

bash ./Anaconda3-2019.03-Linux-x86_64.sh

添加源

速度快, https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

pip也可以添加清华的源:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

参考:https://mirrors.tuna.tsinghua.edu.cn/help/pypi/

配置环境变量

创建新的环境:
conda create -n pytorch
source activate pytorch

安装环境

conda install pytorch torchvision cudatoolkit=9.0 -c pytorch
命令参考: https://pytorch.org/

查看 CUDA 版本: cat /usr/local/cuda/version.txt
查看 CUDNN 版本:cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

conda install jupyter notebook

在环境里安装:conda install ipykernel

python -m ipykernel install --user --name pytorch --display-name "python"

生成配置文件

jupyter notebook --generate-config

修改配置文件

c.NotebookApp.allow_remote_access = True
c.NotebookApp.ip = ‘*’
c.NotebookApp.notebook_dir = ‘/path/’
c.NotebookApp.open_browser = False
c.NotebookApp.port = 9999

启动服务

nohup jupyter notebook --config=jupyter_notebook_config.py > log.out 2>&1 &

扩展插件
pip install jupyter-contrib-nbextensions
jupyter contrib nbextension install --user

jupyter的使用:https://www.jianshu.com/p/91365f343585
设置同一个单元格打印多个变量:https://www.cnblogs.com/everfight/p/juypter-notebook.html
扩展插件的介绍:https://blog.youkuaiyun.com/u013555719/article/details/77446545

安装
conda install scikit-learn
pip install -U matplotlib
pip install easydict
移植

https://blog.youkuaiyun.com/sinat_28442665/article/details/86650152

#通用格式
conda env export -n 项目名 -f environment.yaml

#在env外导出
conda env export -n snakemake-tutorial > snakemake.yml

#在snakemake-tutorial 环境内导出
conda env export > snakemake.yaml
pip freeze > requirements.txt

#查看snakemake.yaml文件
cat snakemake.yaml
name: snakemake
channels:
  - conda-forge
  - bioconda
  - defaults
dependencies:
  - _libgcc_mutex=0.1=main
  - asn1crypto=0.24.0=py35_3
  - bcftools=1.3.1=h84994c4_5
  - bcrypt=3.1.4=py35h14c3975_0
  - bwa=0.7.12=1

#根据文件创建环境变量的通用格式
conda env create --name snakemake --file snakemake.yaml

#创建snakmake环境
conda env create -f snakemake.yaml
pip install -r requirements.txt

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值