当前位置:网站首页>使用d2l包和相关环境配置的一些血泪心得
使用d2l包和相关环境配置的一些血泪心得
2022-07-24 05:15:00 【欣欣草木生】
目录
一 引言
写给:
初学深度学习的同学
缺少环境错误排查经验的同学
以李沐老师B站机器学习课程,dive into deep learning网站为教材学习的同学
以下:
皆为本人所踩的雷 , 也在排查错误中花费了许多时间 , 获得了一些经验
本人使用的cpu版的pytorch
现已经整理碰到的许多的坑 , 也添加了一些自己的分析 , 希望可以帮助到大家
二 关于anaconda的配置
1 anaconda的安装过程
注意点
1 安装的时候最好不要直接安装到c盘(如果c盘空间不富裕的话)
因为它会越来越大 , 直至我重装系统的时候已经有50g大小了
2 安装的时候有个添加到环境变量(add to path)最好勾选上 , 不然可能后边还是要添加到环境变量 , 稍微有些麻烦
2 d2l包和pytorch包的下载
1 创建新环境
最好不要把所有需要的包都直接在base环境里
可以创建一个新环境
创建命令:
conda create -n newd2l python=3.7
newd2l : 这个环境的名称叫做newd2l , 读者可自行更改
py=3.7 : 创建的python版本是3.7
d2l : 这里是l是小写英文字母l , 不是1
提示 : python最好是3.7版本 , 本人起初安装了3.6的版本 , 有一些代码无法运行(因为有更新) , debug好久
例1 本人在3.6中收到 grad can be implicitly created only for scalar outputs的报错 , 但是3.7就可以运行
例2 pip install d2l 搜索到的d2l是0.17.0的版本 , 而不是所需的0.17.5的版本 , 有一些不兼容的地方
2 添加镜像源
为什么要添加镜像源?
anaconda的服务器在境外 , 国内下载速度十分缓慢甚至下载断链失败的情况
使用镜像源可以下载的更快更稳一些
1 . 给conda添加镜像源
按照路径 , 找到 此电脑 - C盘 - 用户 - 你的账户名 - .condarc 文件
如果没找到 , 自己新建一个.condarc文件 , 文件名字是空的 , 就一个.condarc后缀
用记事本方式打开即可
复制并粘贴以下代码以设置镜像源
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- http://pypi.douban.com/simple/
- defaults
show_channel_urls: true
这里添加了3个镜像源 , 自己可以再找别的镜像源按照以上的格式粘贴上去即可
如果你不能修改后缀名
尝试如下操作
以上设置对用conda install 命令来下载包时有效
2 . 给pip添加镜像源
在 此电脑 - C盘 - 用户 - 你的账户名 文件夹里创建一个pip文件夹
在pip 文件夹里创建 pip.ini 文件
记事本方式打开
赋值粘贴以下代码
[global]
index-url = https://pypi.mirrors.ustc.edu.cn/simple/
extra-index-url = https://pypi.mirrors.ustc.edu.cn/simple/
https://mirrors.aliyun.com/pypi/simple/
https://pypi.tuna.tsinghua.edu.cn/simple/
http://pypi.mirrors.ustc.edu.cn/simple/
https://pypi.org/simple/
trusted-host = pypi.mirrors.ustc.edu.cn
pypi.mirrors.ustc.edu.cn
mirrors.aliyun.com
pypi.tuna.tsinghua.edu.cn
pypi.mirrors.ustc.edu.cn
pypi.org
index-url 是设置镜像源 上边设置了多个镜像源
trusted-host 设置信任这些网站
以上设置对用 pip install 命令来下载包时有效
3 . 如果你在科学上网
可以选择暂时关闭科学上网 , 如果执意坚持
还需要设置代理服务器
1 在 .condarc 文件中再添加
proxy_servers:
http: http://127.0.0.1:7893
https: http://127.0.0.1:7893
ssl_verify: false
此处的7893修改成你的端口名
2 在 pip.info 文件中再添加
proxy = http://127.0.0.1:7893
如下图所示

3 d2l包和pytorch包的下载
1 打开anaconda prompt
2 切换到目录二.2.1中你创建的新环境
3 输入 pip install d2l
然后等待 , 如果碰到选择yes or no , 输入y , 敲击回车
等待它下载安装完成
现在d2l 0.17.5 就已经安装好了
4 pytorch的安装
如果你是安装cpu版的torch , 输入
conda install pytorch torchvision torchaudio cpuonly -c pytorch
即可
如果你是安装gpu版的torch , 移步链接
https://zh-v2.d2l.ai/chapter_installation/index.html
有问题请查看评论区和自行搜索
(推荐: gpu更合适
本人由于囊中羞涩 , 无力置换老电脑 , 没有NVIDIA的显卡 , 无奈使用cpu版)
3 kaggle
提供免费算力的宝藏网站
在本人电脑代码由于版本原因出现bug却又找不出原因时 ,
暂时使用了这个网站进行跑代码训练
如何在kaggle中如何导入所需的包?例如d2l?
只要输入
!pip install d2l
点击运行 , 就可以进行d2l这个包的下载了
如果你是属于配置较低的电脑 , 也可以把代码放在这里运行
边栏推荐
- 。单类型数字传感一个应用程.0。 Up- 开址在出厂
- MS simulated written test
- Crazy God redis notes 09
- JMeter FAQs
- Embedded system transplantation [2] - Construction of cross development environment
- The network NN can calculate the NTCP provided by the host system
- finally和return的执行顺序
- Execution sequence of finally and return
- C table data De duplication
- 利用a*启发式搜索解决迷宫寻路问题
猜你喜欢

HCIA NAT experiment
![[postgraduate entrance examination vocabulary training camp] day 10 - capital, expand, force, adapt, depand](/img/9a/a218c46806cf286f0518a72809e084.png)
[postgraduate entrance examination vocabulary training camp] day 10 - capital, expand, force, adapt, depand

酒店IPTV数字电视系统解决方案

Heavy! The 2022 China open source development blue book was officially released

jdbc封装一个父类减少代码重复

Image to image translation with conditional advantageous networks paper notes

Hotel IPTV digital TV system solution

【Pytorch】conv2d torchvision.transforms

Drools 开发决策表

On the dilemma faced by non transferable reputation points NFT SBTS
随机推荐
好的程序员与不好的程序员
Wang Qing, director of cloud infrastructure software research and development of Intel (China): Intel's technology development and prospects in cloud native
[basic 8] - processes and threads
1. Input a 100 point score from the keyboard and output its grade according to the following principles: score ≥ 90, Grade A; 80 ≤ score < 90, grade B; 70 ≤ score < 80, grade C; 60 ≤ score < 70, grade
Accuracy of% connections. Now it is planned to meet the demand. The number of enterprises is enough
How can NFT, whose stars enter the market against the market, get out of the independent market?
generator生成器,只生成两个方法
Emqx simple to use
【【【递归】】】
【sklearn】PCA
How to avoid the most common mistakes when building a knowledge base?
Teach you how to weld CAD design board bottom (for beginners) graphic tutorial
Read "effective managers - Drucker"
Transpose of array sparse matrix
1、基于增量式生成遮挡与对抗抑制的行人再识别
)To feed back to the application layer or into multiple format documents:
SSM整合
Image to image translation with conditional advantageous networks paper notes
finally和return的执行顺序
FTP file transfer protocol