You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1KB

  1. # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
  2. """
  3. utils/initialization
  4. """
  5. def notebook_init(verbose=True):
  6. # Check system software and hardware
  7. print('Checking setup...')
  8. import os
  9. import shutil
  10. from utils.general import check_requirements, emojis, is_colab
  11. from utils.torch_utils import select_device # imports
  12. check_requirements(('psutil', 'IPython'))
  13. import psutil
  14. from IPython import display # to display images and clear console output
  15. if is_colab():
  16. shutil.rmtree('/content/sample_data', ignore_errors=True) # remove colab /sample_data directory
  17. if verbose:
  18. # System info
  19. # gb = 1 / 1000 ** 3 # bytes to GB
  20. gib = 1 / 1024 ** 3 # bytes to GiB
  21. ram = psutil.virtual_memory().total
  22. total, used, free = shutil.disk_usage("/")
  23. display.clear_output()
  24. s = f'({os.cpu_count()} CPUs, {ram * gib:.1f} GB RAM, {(total - free) * gib:.1f}/{total * gib:.1f} GB disk)'
  25. else:
  26. s = ''
  27. select_device(newline=False)
  28. print(emojis(f'Setup complete ✅ {s}'))
  29. return display