Apple Mac M1 chip

I seem to have a problem getting the docker image

to run on my Apple Mac with the M1 chip. I don’t see any files getting installed.

The docker example they have seems to run fine. Any thoughts ?

hi @Raghavan , welcome to the course!

Could you give more information about what command you have tried and what is the error?
Do you succeed in running any docker image or just fail to run this image?

I see many learners succeed running docker on M1 chip so it is likely that you can run it too. :slightly_smiling_face:


Strangely, when I tried this today, it worked ! Don’t know what changed from last night.
Thanks !!

Now Tensorflow has an issue running. I get the following error and the kernel crashes. Any suggestions ?
It is executing the cell

def detect_and_draw_box(filename, model=“yolov3-tiny”, confidence=0.5):
import cvlib as cv

Saving file at /work/server.ipynb

2021-06-02 16:31:30.488698: F tensorflow/core/lib/monitoring/] Check failed: bucket_limits_[i] > bucket_limits_[i - 1] (0 vs. 10)

qemu: uncaught target signal 6 (Aborted) - core dumped

I set up my virtual environment as detailed in the following link. Now I can run the files and do the exercise.


Good to hear that you have a working environment now.
For your information, another learner found that tensorflow==2.4.1 is compatible with M1.

Hi! I’m experiencing the same issue with my Mac M1.
For the docker install, everything runs smoothly up to the point where I open my localhost window and access the work folder with my token. I find the work folder but nothing in it.

Using the other way of downloading the repo and opening the server notebook on jupyterlab works fine up to the point where I import cvlib. When running this line, the kernel always crashes. Any idea why ? Thank you

hi @michaelhodara , welcome to the course!
In case you found nothing in the folder, there is a chance you had not downloaded all the files. Can you reference the following comment to download all the files and then try the docker again?

It seems @Raghavan technique worked for me as well! Thanks for the tips.

Thank you as well @travinhcuong for your help!

1 Like

I encountered with similar issues on Mac M1, below is my way out, hope it help.

3 issues I encountered:

  1. cv2 module does’t work
  2. cvlib module doesn’t work
  3. tensorflow doesn’t work

The logic of way out is to build a virtual environment (venv), and install the module we need in it, then run the Jupiter lab with the new venv.

  1. Install cv2 module by building an virtual environment: tutorial

  2. Install cvlib and Jupiter lab:

    • activate the venv built above with terminal: conda activate your_venv_name

    • install cvlib: pip install cvlib

      • if there’s an error like: ERROR: Command errored out with exit status 1, then try to install the external library before install cvlib, typing :

        • brew install libtiff libjpeg webp little-cms2
        • brew install freetype harfbuzz fribidi
      • then install pillow with:

        • python3 -m pip install --upgrade pip
        • python3 -m pip install --upgrade Pillow
      • finally install cvlib:

        • pip install cvlib
    • reference

  3. Install tensorflow within venv: tutorial

  4. Install jupyter lab within venv: pip install jupyterlab

  5. Run juypter lab in the venv we built:

    • open terminal and typing:

      • conda activate your_venv_name

      • jupyter lab

Above is my case, please check if it match your situation before applying it.


Just an update on speed. In Week 2 exercise, training is supposed to take about 20 minutes on a GPU. I ran it on the M1 and it took 16 minutes. So we are getting GPU speed using the M1.

1 Like

Hello Raghavan!
I am running into the same issues. Both Docker and virtual environment methods seem to be failing for me. Did you manage to run the week 1 lab in a virtual environment? I see you installed tensorflow following the tutorial. What about other packages? The kernel keeps dying when importing cvlib for me, and I have run out of solutions.

Try this method from Python Tensorflow and OpenCV on Apple Silicon M1 - Stack Overflow.
I just created a new environment and tried it out and CV2 works fine. I was able to run week1 and week2 labs entirely on my laptop including training and it was faster than the GPU number quoted in the lab.

pip3 install --upgrade --force --no-dependencies \$(uname -m).whl \$(uname -m).whl
python -c 'import tensorflow as tf; print(tf.__version__)' 
conda install opencv
python -c 'import tensorflow as tf; import cv2; print(cv2.__version__); print(tf.__version__)'

You made sure you had condo installed as recommended in the article and are you using conda ? Because you cannot install OpenCV directly if you follow instructions - it will not find the OpenCV version compatible with M1.
Please make sure you followed the installation procedure exactly

Hello everyone,
I could run the ungraded week1 project in my M1 mac following these instructions:

  1. Follow instructions in github for cloning the repo (machine-learning-engineering-for-production-public/course1/week1-ungraded-lab at main · https-deeplearning-ai/machine-learning-engineering-for-production-public · GitHub)

  2. Do what this response says for installing tensor flow and opencv in a M1 mac Python Tensorflow and OpenCV on Apple Silicon M1 - Stack Overflow

  3. Move to the machine-learning-engineering-for-production-public/course1/week1-ungraded-lab directory

  4. Edit the requirements.txt file. Delete opencv-python-headless== and tensorflow==2.3.1 lines.

  5. Follow with step 2 in github instructions ( 2. Installing dependencies using PIP)

Hope this helps

1 Like

The docker container on my Apple Mac M1 crashes when I open and try to run the server.ipynb file. I cannot trust the file before the container crashes. Any assistance will be appreciated.

I have the same problem. work folder appears when using docker but in jupyter lab server, I can’t import cvlib. Although I have tf, cv2 and cvlib installed correctly and I can’t import the package.

I used tensorflow / numpy on M1 / Monterey | Apple Developer Forums to install tf. Other methods that were mentioned in this thread didn’t work for me for some reason.

As for opencv, I used to install.

Anyone has any idea why cvlib is not working?

I was able to run on my M1 Mac with miniconda & installing TensorFlow & OpenCV as follows:


Reference: Getting Started with tensorflow-metal PluggableDevice

Install Tensorflow dependencies:

conda install -c apple tensorflow-deps

Install base TensorFlow:

python -m pip install tensorflow-macos

Install tensorflow-metal plugin:

python -m pip install tensorflow-metal


Reference: How to Safely Install OpenCV on the Mac M1

Add conda-forge to your .condarc config file:

conda config --add channels conda-forge

Install OpenCV:

conda install -c conda-forge opencv===4.5.3

Test that OpenCV has installed correctly by checking the version:

python -c "import cv2; print(cv2.__version__)" 

This should print out the installed OpenCV Version:


Modifying requirements.txt

Comment out the following dependencies in requirements.txt:

  • opencv-python-headless
  • tensorflow

See this modified README.

1 Like

Just to confirm: @estherjk’s method works perfectly, and is very easy and convenient compared to earlier workarounds. Make sure to specify the OpenCV version as described – cvlib will run into issues with the latest one otherwise (as of Aug '22, that is)

1 Like

Awesome! Thanks a lot @estherjk for finding the method and to @piliv for confirming. I will add this to the documentation during the course of this week.