yolov7: cannot import amp from torch.cuda

671 Views Asked by At

I'm running yolov7 to train on my custom data.

To train I have done following things:

  1. Install nvidia cuda 9.0
  2. Install cudnn 9.0 in "\NVIDIA GPU Computing Toolkit\CUDA\v9.0" directory.
  3. Installed pytorch and torchvision for compatible cuda9.0 by following this link

Above link strictly says that it requires torch version to be less than 1.1.0 for cuda 9.0

Versions:

python 3.7.1

torch==1.1.0
torchvision==0.3.0

Full Error:

(venv37) PS D:\aiml_python_code\yolov7-main> python .\train.py --batch-size 8 --epochs 100 --img 640 640 --data .\data\c
ar_dataset.yaml --hyp .\data\hyp.scratch.custom.yaml --cfg .\cfg\training\yolov7_custom.yaml --name yolov7-custom --weig
hts yolov7.pt --device 0 --workers 1

Traceback (most recent call last):
  File ".\train.py", line 19, in <module>
    from torch.cuda import amp
ImportError: cannot import name 'amp' from 'torch.cuda' (D:\aiml_python_code\yolov7-main\venv37\lib\site-packages\torch\
cuda\__init__.py)

And I'm getting torch.cuda.is_available() as True

My guess is that torch 1.1.0 does not have amp and above versions of torch do. So how can i resolve this issue with having "latest version incompatibility" in mind

1

There are 1 best solutions below

0
On

amp is introduced to pytorch after V1.6

you can update your pytorch from the official website