(Raspberry Pi) Solved the problem: AssertionError: Torch not compiled with CUDA enabled

AssertionError: Torch not compiled with CUDA enabled

This error is because the downloaded torch does not have cuda, and an error occurs when running. After checking, add:

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

must not use Chinese quotation marks

 

Change the place where .cuda() appears in the rest of the code to .to(device) to run in a gpu-free environment.

NameError: name 'torch' is not defined

direct

import torch

NameError: name 'jit' is not defined

from torch import from_numpy, jit

Reference: https://blog.csdn.net/m0_37663482/article/details/88893603

Guess you like

Origin blog.csdn.net/dujuancao11/article/details/114006234