Lightning-AI / dl-fundamentals

Deep Learning Fundamentals -- Code material and exercises
https://lightning.ai/pages/courses/deep-learning-fundamentals/
320 stars 149 forks source link

`ZeroDivisionError` in 8.2, 8.7 and other #99

Closed GegznaV closed 4 months ago

GegznaV commented 4 months ago

On my Windows 10, with Python 3.11 and:

torch       : 2.1.2+cu121
transformers: 4.37.2
datasets    : 2.17.0
lightning   : 2.1.3

The code in many files of sections 8.2 and 8.7:

download_dataset()

df = load_dataset_into_to_dataframe()
partition_dataset(df)

result in:

     19 duration = time.time() - start_time
     20 progress_size = int(count * block_size)
---> 21 speed = progress_size / (1024.0**2 * duration)
     22 percent = count * block_size * 100.0 / total_size
     24 sys.stdout.write(
     25     f"\r{int(percent)}% | {progress_size / (1024.**2):.2f} MB "
     26     f"| {speed:.2f} MB/s | {duration:.2f} sec elapsed"
     27 )

ZeroDivisionError: float division by zero

I did not check other units yet.

The problem is that the computed difference in time is 0, so this creates the error.