《动手学深度学习(PyTorch)》环境搭建

Anaconda和Miniconda简介

        Anaconda 是专门为了方便使用 Python 进行数据科学研究而建立的一组软件包,涵盖了数据科学领域常见的 Python 库,并且自带了专门用来解决软件环境依赖问题的 conda 包管理系统。主要是提供了包管理与环境管理的功能,可以很方便地解决多版本python并存、切换以及各种第三方包安装问题。Anaconda利用工具/命令conda来进行package和environment的管理,并且已经包含了Python和相关的配套工具。

        conda可以理解为一个工具,也是一个可执行命令,其核心功能是包管理与环境管理。包管理与pip的使用类似,环境管理则允许用户方便地安装不同版本的python并可以快速切换。

Linux环境安装配置

下载Anaconda

Anaconda下载网址:

Free Download | 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更换镜像源

上海交通大学 Linux 用户组 软件源镜像服务

复制文本后,在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
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值