d2l-ai / d2l-en

Interactive deep learning book with multi-framework code, math, and discussions. Adopted at 500 universities from 70 countries including Stanford, MIT, Harvard, and Cambridge.
https://D2L.ai
Other
22.45k stars 4.19k forks source link

Can't build the book on MacOS when trying to add MLX implementation #2583

Open PRESIDENT810 opened 5 months ago

PRESIDENT810 commented 5 months ago

I'm trying to add Apple's MLX code implementation, but when I am trying to build the html book I run into this when running d2lbook build html:

Traceback (most recent call last):
  File "/Users/zhongkaining/Library/Python/3.9/bin/d2lbook", line 8, in <module>
    sys.exit(main())
  File "/Users/zhongkaining/Library/Python/3.9/lib/python/site-packages/d2lbook/main.py", line 25, in main
    commands[args.command[0]]()
  File "/Users/zhongkaining/Library/Python/3.9/lib/python/site-packages/d2lbook/build.py", line 43, in build
    getattr(builder, cmd)()
  File "/Users/zhongkaining/Library/Python/3.9/lib/python/site-packages/d2lbook/build.py", line 55, in warp
    func(self)
  File "/Users/zhongkaining/Library/Python/3.9/lib/python/site-packages/d2lbook/build.py", line 342, in html
    self.rst()
  File "/Users/zhongkaining/Library/Python/3.9/lib/python/site-packages/d2lbook/build.py", line 55, in warp
    func(self)
  File "/Users/zhongkaining/Library/Python/3.9/lib/python/site-packages/d2lbook/build.py", line 316, in rst
    self.eval()
  File "/Users/zhongkaining/Library/Python/3.9/lib/python/site-packages/d2lbook/build.py", line 55, in warp
    func(self)
  File "/Users/zhongkaining/Library/Python/3.9/lib/python/site-packages/d2lbook/build.py", line 160, in eval
    _process_and_eval_notebook(scheduler, src, tgt, run_cells,
  File "/Users/zhongkaining/Library/Python/3.9/lib/python/site-packages/d2lbook/build.py", line 515, in _process_and_eval_notebook
    scheduler.add(1, num_gpus, target=_job,
  File "/Users/zhongkaining/Library/Python/3.9/lib/python/site-packages/d2lbook/resource.py", line 102, in add
    assert num_cpus <= self._num_cpus and num_gpus <= self._num_gpus, \
AssertionError: Not enough resources (CPU 2, GPU 0 ) to run the task (CPU 1, GPU 1)

Looks like building this book requires a GPU, but on MacBook there is no Nvidia GPU. If I want to build on other OS, then I don't MLX will be available on those platforms since this is kinda specifically designed for MacOS.

I think this problem blocks people who attempts to contribute MLX code to this book.