当前位置:网站首页>【PYTORCH】RuntimeError: torch. cuda. FloatTensor is not enabled.

【PYTORCH】RuntimeError: torch. cuda. FloatTensor is not enabled.

2022-06-13 07:46:00 neu_ eddata_ yjzhang

The reason for this error is that you are installing cpu Version of pytorch Up operation GPU Version of pytorch Code for .

resolvent :

Place the error in ".cuda()" Switch to ".cpu()"

Some of the downloaded code needs GPU Calculation , And computers don't GPU, At this point, you can add the following code at the beginning of the code to obtain whether the current computer has GPU
# gpu or not
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

And then in the code use .to(device) Replace .cuda() perhaps .cpu() Can be found in GPU On your computer GPU Computational acceleration , In the absence of GPU On your computer CPU Calculation , But it's slower
 

原网站

版权声明
本文为[neu_ eddata_ yjzhang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202270547027560.html