ZeroDivisionError: integer division or modulo by zero

The problem shows as follows:
“Traceback (most recent call last):
File “train.py”, line 26, in
train_net(config)
File “train.py”, line 17, in train_net
solver = Solver(config, data_loader=data_loader, device=“cuda”)
File “/home/zhangwei/PSGAN-master/psgan/solver.py”, line 41, in init
self.snapshot_step = config.LOG.SNAPSHOT_STEP // torch.cuda.device_count()”
Can someone tell me what this problem is?

It seems that no GPU is detected on your system in:

self.snapshot_step = config.LOG.SNAPSHOT_STEP // torch.cuda.device_count()

which would trigger a division by 0.

Your system either doesn’t have a GPU, in which case you should remove the device_count() call and fix the code appropriately, or the GPU is not detected if you’ve installed the PyTorch CPU binaries or e.g. are using a too old NVIDIA driver.

Thank u very much.I have solved my problem! :blush: