У меня был рабочий код на основе Fastai 2.0 с версией PyTorch ~ 1 года назад, а также предыдущая версия CUDA, кажется, какая-то версия 11.x. . Версия Jetpack была 5.x.
Теперь я прошил последнюю версию Jetpack на Orin с Ubuntu 22.04. Теперь это Jetpack 6.0 с CUDA 12.
В PyTorch установлена поддержка CUDA:
Код: Выделить всё
Python 3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>>
>>> device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
>>> print(f"Using device: {device}")
Using device: cuda
Код: Выделить всё
>>> import fastai
>>> print(fastai.__version__)
2.7.17
>>> import torch
>>> print(torch.__version__)
2.4.0a0+07cecf4168.nv24.05
Код: Выделить всё
# Perform batch inference
torch.cuda.synchronize()
start_inference = time.time()
with torch.no_grad():
# Put the model into inference mode
accumulated_output = []
logger.info("Setting inference mode now ...")
with torch.inference_mode():
for data in infer_loader:
data = data.cuda()
logger.info(f"Calling learner now: {data} ...")
logger.info(f"Learner is: {learner}")
output = learner(data)
logger.info("Done calling learner ...")
for tensor_output in output.data.cpu():
accumulated_output.append(tensor_output)
# Time the inference work
torch.cuda.synchronize()
end_inference = time.time()
logger.info(f"Inference time: {end_inference - start_inference}")
Код: Выделить всё
output = learner(data)
Код: Выделить всё
Failed to perform inference: hasattr(): attribute name must be string
Код: Выделить всё
[2024-10-07 18:44:06,229] __main__ {process_frame_utils.py:258} INFO - Creating data loader now ...
[2024-10-07 18:44:06,230] __main__ {process_frame_utils.py:274} INFO - Setting inference mode now ...
[2024-10-07 18:44:06,757] __main__ {process_frame_utils.py:278} INFO - Calling learner now: tensor([[[[-2.1179, -2.1179, -2.1179, ..., -2.1179, -2.1179, -2.1179],
...
[-1.8044, -1.8044, -1.8044, ..., -1.8044, -1.8044, -1.8044]]]], device='cuda:0') ...
[2024-10-07 18:44:06,759] __main__ {process_frame_utils.py:279} INFO - Learner is:
[2024-10-07 18:44:06,798] __main__ {process_frame_utils.py:370} ERROR - Error: Failed to perform inference: hasattr(): attribute name must be string
Как я могу это исправить?
Подробнее здесь: https://stackoverflow.com/questions/790 ... fails-with