出现错误:
python 版本:
解决方法:https://blog.csdn.net/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:两个关键字(
device
andnon_blocking
)可以用来调用cuda( ) ,device是选取显卡序列号的。
-
non_blocking
(bool):
IfTrue
and 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 pipenv
https://github.com/quark0/darts/pull/25
https://pytorch.org/docs/stable/tensors.html#torch.Tensor.cuda
我的解决方法:pip install pipenv
直接使用cuda() 解决了这个问题