super-gradients icon indicating copy to clipboard operation
super-gradients copied to clipboard

No module named 'torch.mps'

Open ahsanulhabib opened this issue 1 year ago • 4 comments

I am getting the following error while running the Kaggle notebook for detecting potholes. Is it related to the pytorch version? My current pytorch version is 2.0.0


ModuleNotFoundError Traceback (most recent call last) Cell In[59], line 1 ----> 1 trainer.train(model=model, 2 training_params=train_params, 3 train_loader=train_data, 4 valid_loader=val_data)

File /opt/conda/lib/python3.10/site-packages/super_gradients/training/sg_trainer/sg_trainer.py:1037, in Trainer.train(self, model, training_params, train_loader, valid_loader, additional_configs_to_log) 1034 self._prep_net_for_train() 1036 # SET RANDOM SEED -> 1037 random_seed(is_ddp=device_config.multi_gpu == MultiGPUMode.DISTRIBUTED_DATA_PARALLEL, device=device_config.device, seed=self.training_params.seed) 1039 silent_mode = self.training_params.silent_mode or self.ddp_silent_mode 1040 # METRICS

File /opt/conda/lib/python3.10/site-packages/super_gradients/training/utils/utils.py:307, in random_seed(is_ddp, device, seed) 298 """ 299 Sets random seed of numpy, torch and random. 300 (...) 304 :param seed: int, random seed to be set 305 """ 306 rank = 0 if not is_ddp else int(device.split(":")[1]) --> 307 torch.manual_seed(seed + rank) 308 np.random.seed(seed + rank) 309 random.seed(seed + rank)

File /opt/conda/lib/python3.10/site-packages/torch/random.py:42, in manual_seed(seed) 39 if not torch.cuda._is_in_bad_fork(): 40 torch.cuda.manual_seed_all(seed) ---> 42 return default_generator.manual_seed(seed)

ModuleNotFoundError: No module named 'torch.mps'

ahsanulhabib avatar May 10 '23 10:05 ahsanulhabib

Hi @ahsanulhabib, It looks like its due to your pytorch version, you can see if this solves it: https://stackoverflow.com/questions/72535034/module-torch-has-no-attribute-has-mps

Louis-Dupont avatar May 10 '23 11:05 Louis-Dupont

I don't think pytorch 2.0 is supported yet, I had some issues previously. I haven't tried the notebook that you are referencing but so far I haven;t had much issues with these installs:

! pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113 &> /dev/null
! pip install super-gradients
! pip install pytorch-quantization==2.1.2 --extra-index-url https://pypi.ngc.nvidia.com &> /dev/null
! pip install matplotlib==3.1.3 &> /dev/null
! pip install --upgrade psutil==5.9.2 &> /dev/null
! pip install --upgrade pillow==7.1.2 &> /dev/null```

itberrios avatar May 11 '23 00:05 itberrios

Can you please write the issue you had when installing? Note that you can take out &> /dev/null to see the full install logs.

Meanwhile, you can also try to import torch and torvision again after you installed SG and see if this helps

Louis-Dupont avatar May 11 '23 11:05 Louis-Dupont