Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'torch' has no attribute 'compile'

Tags:

torch

I have tried using @torch.compile before the def of my function but I obtained the AttributeError: module 'torch' has no attribute 'compile' .

I have installed torchtriton as in the tutorial. Any ideas?

I do not find any clues about similar issues.

like image 956
Dawid Jeczmionek Avatar asked Jun 05 '26 21:06

Dawid Jeczmionek


1 Answers

The reason is that compile is only available for PyTorch > 2.0 (https://pytorch.org/get-started/pytorch-2.0/) Either you have to install PyTorch > 2.0 like this (but is unstable):

!pip3 install numpy --pre torch --force-reinstall --index-url https://download.pytorch.org/whl/nightly/cu117

or just delete the compile. Compile only makes the model faster, but you should be able to train the model without compile and other PyTorch versions as well.

like image 97
Philipp Dingfelder Avatar answered Jun 08 '26 11:06

Philipp Dingfelder