Anaconda和Miniconda简介
Anaconda 是专门为了方便使用 Python 进行数据科学研究而建立的一组软件包,涵盖了数据科学领域常见的 Python 库,并且自带了专门用来解决软件环境依赖问题的 conda 包管理系统。主要是提供了包管理与环境管理的功能,可以很方便地解决多版本python并存、切换以及各种第三方包安装问题。Anaconda利用工具/命令conda来进行package和environment的管理,并且已经包含了Python和相关的配套工具。
conda可以理解为一个工具,也是一个可执行命令,其核心功能是包管理与环境管理。包管理与pip的使用类似,环境管理则允许用户方便地安装不同版本的python并可以快速切换。
Linux环境安装配置
下载Anaconda
Anaconda下载网址:
最新版Anaconda下载链接:
https://repo.anaconda.com/archive/Anaconda3-2022.10-Linux-x86_64.sh
Anaconda换源
修改condarc文件
vim ~/.condarc
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
conda clean -i 清除索引缓存,保证用的是镜像站提供的索引。
安装环境
创建环境
conda create –n d2l python=3.9
然后
#激活环境
conda activate d2l
使用pip安装库文件
pip install numpy pandas matplotlib torch torchvision torchaudio jupyterlab -i https://mirror.sjtu.edu.cn/pypi/web/simple
git安装
# ubuntu 环境
apt install git
# CentOS环境
yum install git
下载课程代码
git clone https://openi.pcl.ac.cn/Datawhale/d2l/
Windows环境安装配置
Minicodna 下载地址:
Miniconda — conda documentation
更换镜像源
Conda更换镜像源
复制文本后,在Anaconda Powershell Prompt 中输入:
#注意有个小点.在"condarc"的前面
> notepad .condarc
粘贴刚刚复制的文本,保存文件后关闭
default_channels:
- https://mirror.sjtu.edu.cn/anaconda/pkgs/r
- https://mirror.sjtu.edu.cn/anaconda/pkgs/main
custom_channels:
conda-forge: https://mirror.sjtu.edu.cn/anaconda/cloud/
pytorch: https://mirror.sjtu.edu.cn/anaconda/cloud/
channels:
- defaults
最后在Anaconda Powershell Prompt 中输入:
#清除源缓存,以应用镜像源
> conda clean -i
Git安装与使用
下载地址:Git - Downloads
加速地址:GitHub Proxy 代理加速
Git学习地址:计算机教育中缺失的一课 · the missing semester of your cs education
下载课程代码
在指定目录打开终端,或者使用 cd 命令改变终端路径:
cd C:\Coding\d2l
在当前终端中输入:
# d2l 课程资源
git clone https://github.com/d2l-ai/d2l-zh.git
# d2l 幻灯片资源
git clone https://github.com/d2l-ai/d2l-pytorch-slides.git
《动手学深度学习》环境搭建
创建与激活Conda
创建Conda环境:
# conda环境创建
> conda create -n d2l python=3.9
激活环境:
#激活d2l环境,不同环境包版本不同!
> conda activate d2l
第三方库安装
#必装库
> pip install d2l torch
#所有库
> pip install d2l torch torchvision rise