Running notebooks locally - tests failing due to version diffs

I see… I can smell something but let’s see…

I ran

docker run --rm -it -p 8888:8888 -v .:/coursera mbjarland/coursera-dl-specialization-apple-silicon bash

but it gave me

WARNING: The requested image's platform (linux/arm64) does not match the detected host platform (linux/amd64/v3) and no specific platform was requested
exec /bin/bash: exec format error

The first line is likely due to Apple VS. Non-Apple
But the second line, I am not sure.

In fact, maybe I should try to run W2A1 on my machine directly. I have a feeling it is going to pass the tests because my machine can reproduce the random numbers. Then it is likely to be platform dependent… but before I go too far, let me verify it first.

Writing from phone so I’ll keep it short. The exec format error is most probably an architecture issue as well, trying to run arm code on a non-arm machine.

Hi @mbjarland

No problem. I think now the concern isn’t about the image.

Some observations to share.

  1. My own machine was not able to pass the test and failed in the same way you shared (although I have not tried to match any version at all - so some packages may use the same version and some not).

  2. The exercise we fail to pass actually uses constant initalizer, so no randomness at all. I traced back for the point where my results start to deviate from the lab’s and I located it.

  3. Turns out it seems to be a rounding issue. At that point, my machine gave me a 191.99983 in one of the tensor elements, but the lab gave me 192.

  4. in both my machine and the lab, they say the resolution for their float32 is 1e-6, so pretty marginal.

  5. Then I ran tf.keras.backend.set_floatx('float64') in both my machine & the lab, in order to use higher resolution float

  6. now both my machine & lab show the same result, and they both fail the test because they are more precise now. :sweat_smile:

Therefore, for that exercise alone, nothing to do with random numbers, but a rounding issue. We need to figure this out before we can move on. (Maybe you can verfiy this with your image?)

Raymond

@mbjarland,

I have a feeling but I can’t explain like a pro about it, the lab’s env uses gcc version 9.4.0, would it be very difficult for you to somehow have that version of gcc in the image and then everything including the tensorflow was built on it?

I really can’t explain why I am suggesting this, but this is something I get from my search, so if it is very difficult, then it might not worth trying it.

Raymond

Looking into it…

Ok seems like it is not entirely trivial to change gcc version (the python version was compiled with). It would most probably involve changing the base image from one which comes with python 3.8.0 to one which comes without python but instead comes with gcc 9.4.0 and then compiling python from source…followed by compiling tensorflow from source etc.

Not impossible, but not a quick thing either. Will see if I get time to try this out in more detail in the next day or two. In the mean time if you find anything else relevant, let me know. I get the feeling that we have strayed far enough away from the original problem that the chances of us barking up the wrong tree are significant at this point.

Agreed. Perhaps we should look into the cause of the rounding issue first and put gcc aside for the time being. Again, I am not totally sure that changing the gcc will worth it. It was just from some discussions I found.

@mbjarland, please hold off incorporating gcc 9.4 into the image for now, because I may be able to pretty quickly install an earlier ubuntu with gcc 9. I will explore that option tomorrow my time, and if I can, then we know whether it can make any difference…

You may also look into the exact cause for that rounding issue.

Hi @mbjarland,

So, I installed a Ubuntu-20.04 equipped with gcc 9.4.0, and installed the same version of tensorflow, numpy, matplotlib and scipy as used in the lab environment.

Then, the same problem.
image

We need new leads.

Raymond

The gcc version printed is the one python was compiled with, i.e. to change it you would need to recompile python.

If anybody with some mileage with the online environments and/or python/tensorflow in general feel like chiming in with potential causes for the diffs that would be much appreciated.

2025-04-17T18:30:00Z
hello sir ,
can you kindly eloborate the process as I am a new learner and want to set up my local environment for both machine learning and deep learning specalization courses,
a step by step guide so that I can set up and learn more on those paths. I am eager to learn more about mlops ansd devops
Thanking you in advance.

If you’re new to these courses, the first point to make is that you don’t really need a local environment: the courses are self-contained and can all be done on the course website. If you later want to create and run neural network models on your own, you have a number of options: there are other online environments like Google Colab which support Jupyter notebooks or you can run them locally. You can even create models locally without the need for Jupyter notebooks.

There are no official and complete instructions for setting up local environments, because there are too many variations. The way to start is to read this thread from the beginning and follow all the links and suggestions given above. The higher level point is that if you are going to play these games, then you need to develop your own problem solving skills as described on this thread. The web has lots of support info available for the searching.