错误记录-12.11
目录Pytorch: Can't call numpy() on Variable that requires grad. Use var.detach().numpy() insteadPytorch: Can’t call numpy() on Variable that requires grad. Use var.detach().numpy() instead将tensor1.numpy
目录
-
-
- Pytorch: Can't call numpy() on Variable that requires grad. Use var.detach().numpy() instead
- python 出现 KeyError: 0 解决
- ModuleNotFoundError: No module named 'ignite.engine'
- RuntimeError: "addmm_cuda" not implemented for 'Long'
- Trying to pass too many CPU scalars to CUDA kernel!
- tensorboard---> Unable to get first event timestamp for run Dec12_13-02-42_server-X10DRi: No event timestamp could be found
- RuntimeError: copy_if failed to synchronize: cudaErrorIllegalAddress: an illegal memory access was encountered
- SyntaxError: ‘break‘ outside loop
- jupyter出现 500 : Internal Server Error
-
Pytorch: Can’t call numpy() on Variable that requires grad. Use var.detach().numpy() instead
将tensor1.numpy()
修改为 tensor1.detach().numpy()
参考
python 出现 KeyError: 0 解决
原因是:字典中使用不存在的键来取值,键 0 不存在,检测代码错误就行。
ModuleNotFoundError: No module named ‘ignite.engine’
代码一开始提示说没有ignite模块,直接pip install ignite
,运行后出现上面的错误,原因是 ignite 安装不是简单的pip,看GitHub上的说明,应该是pip install pytorch-ignite
github链接
RuntimeError: “addmm_cuda” not implemented for ‘Long’
意思就是不支持long在cuda运算时,只能把类型改了
Trying to pass too many CPU scalars to CUDA kernel!
错误原因是把cpu张量放到CUDA中运行了,解决就是看报错那行的变量的类型,把cpu类型加上 to('cuda')
tensorboard—> Unable to get first event timestamp for run Dec12_13-02-42_server-X10DRi: No event timestamp could be found
原因是没有在程序结束的时候关闭写入
tensorboardX使用流程
from tensorboardX import SummaryWriter
writer = SummaryWriter()
# 添加要记录的变量
writer.add_scalar("testnor/reward", eval_reward, i)
# 关闭
writer.close()
RuntimeError: copy_if failed to synchronize: cudaErrorIllegalAddress: an illegal memory access was encountered
导致原因可能有两种:
- 忘记了model.to(device)
- pytorch版本不兼容,在使用transformers包的的时候可能有类似的情况出现
这个的意思是遇到非法的内存访问,这里我是因为模型在gpu上,但是测试的时候传入的数据和处理都在cpu上,所以就是无法访问在gpu上的模型
SyntaxError: ‘break‘ outside loop
break只能用于while循环或者for循环中,如果在if条件语句下使用则会报错:SyntaxError: ‘break’ outside loop。但是如果if条件语句是套在while循环或者for循环内部的,则break可以使用。
jupyter出现 500 : Internal Server Error
sudo pip install --upgrade "ipython[all]"
注意:确保输入带双引号的 ipython 和 [all]
更多推荐
所有评论(0)