出现错误:

python 版本:

解决方法:https://blog.youkuaiyun.com/m0_37644085/article/details/92780697
原因:
- python3.7已经移除了async关键字,而用non_blocking代替。(导致apache-airflow也出了问题)
-
cuda()本身也没有async. 构造函数如下:cuda(device=None, non_blocking=False) → Tensor
解决办法:
直接用cuda()- 用
async_ 代替 - 用non_blocking代替。ps:两个关键字(
deviceandnon_blocking)可以用来调用cuda( ) ,device是选取显卡序列号的。 -
non_blocking(bool):
IfTrueand the source is in pinned memory, the copy will be asynchronous with respect to the host. Otherwise, the argument has no effect. Default:False.- 如果为True且源位于锁定内存中,则副本将与主机异步。 否则,参数无效。 默认值:False。Always good to take a look at the Documentation:
- 更新 Pipenv。
pip install pipenvhttps://github.com/quark0/darts/pull/25
https://pytorch.org/docs/stable/tensors.html#torch.Tensor.cuda
我的解决方法:pip install pipenv
直接使用cuda() 解决了这个问题
本文探讨了Python 3.7中CUDA异步调用的变化,即移除了async关键字并引入了non_blocking参数。提供了如何在PyTorch中正确使用cuda()函数的指导,包括使用non_blocking参数进行异步操作的细节。
2470

被折叠的 条评论
为什么被折叠?



