ModuleNotFoundError: No module named 'torch._dynamo'

Hi Team,

Im using pytorch for medical image segmentation. My cuda gpu version is 11.4 so I used pytorch previous version compatible for my cuda as follows

# CUDA 11.3
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3 -c pytorch

I have limitation to upgrade my cuda so I have to install package below 11.4

for this pytorch package I got an error as follows
File “/home/students/studbhara1/nnUNet/nnunetv2/run/”, line 2, in
from torch._dynamo import OptimizedModule
ModuleNotFoundError: No module named ‘torch._dynamo’

how can I resolve this error as latest version of pytorch dont support cuda 11.3.

Kindly do guide me in this regards

Your locally installed CUDA toolkit won’t be used unless you build PyTorch from source or custom CUDA extensions. If you want to use the new Dynamo util., install the latest release.

I already Installed latest pytorch 2.1.1 but I get runtime error as the Nvidia gpu version is too old (which I cant upgrade due to limitation of access issue) or alternatively downgrade pytorch . So I choose to downgrade pytorch 1.11.0. But this version doesn’t support dynamo.

In such case I would like to know which starting version of pytorch support dynamo as well as compatible with the nvidia version cuda 11.4!!

Again, the locally installed CUDA version doesn’t matter, only the NVIDIA driver.
Dynamo support starts with PyTorch 2.0, so you could try to install the binaries shipping with CUDA 11.8 and check if your driver would support these or is also too old.