pytorch入门资源

1,书以及配套代码

pytorch-book:PyTorch tutorials and fun projects including neural talk, neural style, poem writing, anime generation
https://github.com/chenyuntc/pytorch-book
这是书籍《深度学习框架PyTorch:入门与实践》的对应代码,但是也可以作为一个独立的PyTorch入门指南和教程。
在这里插入图片描述

2,调试方法

pytorch Debug —交互式调试工具Pdb (ipdb是增强版的pdb)-1-在pytorch中使用
https://www.cnblogs.com/wanghui-garcia/p/10648849.html

3,安装步骤

安装好pytorch之后,下载pytorch-book,然后创建一个conda环境,安装requirements.txt中的软件包。

 git clone https://github.com/chenyuntc/pytorch-book
 cd pytorch-book/
 
 conda create -n myStudyPytorch
 conda activate myStudyPytorch

pip install -r requirements.txt
pip install ipdb

如果出现如下错误,可以尝试在pip指令后面增加’–user’。具体原因参考pip的官方说明。

Consider using the `--user` option or check the permissions

https://pip.readthedocs.io/en/stable/user_guide/

User Installs
With Python 2.6 came the “user scheme” for installation, which means that all Python distributions support an alternative install location that is specific to a user. The default location for each OS is explained in the python documentation for the site.USER_BASE variable. This mode of installation can be turned on by specifying the --user option to pip install.
Moreover, the “user scheme” can be customized by setting the PYTHONUSERBASE environment variable, which updates the value of site.USER_BASE.
To install “SomePackage” into an environment with site.USER_BASE customized to ‘/myappenv’, do the following:

export PYTHONUSERBASE=/myappenv
pip install --user SomePackage

pip install --user follows four rules:

When globally installed packages are on the python path, and they conflict with the installation requirements, they are ignored, and not uninstalled.
When globally installed packages are on the python path, and they satisfy the installation requirements, pip does nothing, and reports that requirement is satisfied (similar to how global packages can satisfy requirements when installing packages in a --system-site-packages virtualenv).
pip will not perform a --user install in a --no-site-packages virtualenv (i.e. the default kind of virtualenv), due to the user site not being on the python path. The installation would be pointless.
In a --system-site-packages virtualenv, pip will not install a package that conflicts with a package in the virtualenv site-packages. The --user installation would lack sys.path precedence and be pointless.

To make the rules clearer, here are some examples:
From within a --no-site-packages virtualenv (i.e. the default kind):

4,代码运行和调试

1、运行 jupyter notebook

jupyter notebook

2、使用:

在代码开头import ipdb,如下:

import ipdb

在需要开始调试的地方加入语句:

ipdb.set_trace()

3、常用命令:

n (下一个),next单步执行
ENTER (重复上次命令)
q (退出)
p <变量> (打印变量)

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值