jeffheaton / t81_558_deep_learning

T81-558: Keras - Applications of Deep Neural Networks @Washington University in St. Louis
https://sites.wustl.edu/jeffheaton/t81-558/
Other
5.71k stars 3.04k forks source link

Conflict with OpenCV #118

Closed doit-ceo closed 3 years ago

doit-ceo commented 3 years ago

I followed your instruction to get Mac M1 working and it worked perfectly, thanks a lot

But adding openCV to the environment breaks Jupiter (local device)

I can start Jupiter, it but I can't connect to the kernel anymore !

[I 00:46:18.292 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.9/site-packages/ipykernel_launcher.py", line 16, in <module>
    app.launch_new_instance()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.9/site-packages/traitlets/config/application.py", line 846, in launch_instance
    app.start()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.9/site-packages/ipykernel/kernelapp.py", line 477, in start
    ioloop.IOLoop.instance().start()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.9/site-packages/tornado/platform/asyncio.py", line 199, in start
    self.asyncio_loop.run_forever()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.9/asyncio/base_events.py", line 586, in run_forever
    self._check_running()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.9/asyncio/base_events.py", line 578, in _check_running
    raise RuntimeError('This event loop is already running')
RuntimeError: This event loop is already running
[W 00:46:48.855 NotebookApp] Replacing stale connection: 72f26a9e-528d-4d2f-acf8-1e35d3ed569a:d1e830e0554f4f94a0c417a1df912566
[W 00:47:15.308 NotebookApp] Timeout waiting for kernel_info reply from aa60b427-f9b3-48ce-b24d-c870b1fd34c5
/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.9/json/encoder.py:257: UserWarning: date_default is deprecated since jupyter_client 7.0.0. Use jupyter_client.jsonutil.json_default.
  return _iterencode(o, 0)
[W 00:47:19.849 NotebookApp] Nudge: attempt 10 on kernel aa60b427-f9b3-48ce-b24d-c870b1fd34c5
[W 00:47:24.908 NotebookApp] Nudge: attempt 20 on kernel aa60b427-f9b3-48ce-b24d-c870b1fd34c5
[W 00:47:29.965 NotebookApp] Nudge: attempt 30 on kernel aa60b427-f9b3-48ce-b24d-c870b1fd34c5
[W 00:47:35.015 NotebookApp] Nudge: attempt 40 on kernel aa60b427-f9b3-48ce-b24d-c870b1fd34c5
[W 00:47:40.066 NotebookApp] Nudge: attempt 50 on kernel aa60b427-f9b3-48ce-b24d-c870b1fd34c5
[W 00:47:45.104 NotebookApp] Nudge: attempt 60 on kernel aa60b427-f9b3-48ce-b24d-c870b1fd34c5
[W 00:47:50.152 NotebookApp] Nudge: attempt 70 on kernel aa60b427-f9b3-48ce-b24d-c870b1fd34c5
[W 00:47:55.209 NotebookApp] Nudge: attempt 80 on kernel aa60b427-f9b3-48ce-b24d-c870b1fd34c5
[W 00:48:00.261 NotebookApp] Nudge: attempt 90 on kernel aa60b427-f9b3-48ce-b24d-c870b1fd34c5
[W 00:48:05.307 NotebookApp] Nudge: attempt 100 on kernel aa60b427-f9b3-48ce-b24d-c870b1fd34c5
[W 00:48:10.351 NotebookApp] Nudge: attempt 110 on kernel aa60b427-f9b3-48ce-b24d-c870b1fd34c5
jeffheaton commented 3 years ago

Currently OpenCV is not a required component for this course, so it is really out of scope for what I am providing here.

I do know that there are some complexities to installing OpenCV on M1, this might be of help. https://opencv.org/opencv-python-for-apples-m1-chip-a-detective-story-with-a-happy-ending/

doit-ceo commented 3 years ago

@jeffheaton I found that installing TF from here (https://www.youtube.com/watch?v=ykCY_tJbhNw) gave me better results as it truly utilize M1 / ML chip, following your tutorial result in GPU utilization (good) but the youtube above added support for ML and I managed to run your notebook with no CPU or GPU activities, also it was compatible with openCV