Setting up local environment

There was a great post about this on the old forums from mentor Kanwalinder Singh. I will try to bring over enough of the information to get you started. The trick is that you use “pip” (not “conda”) to capture the versions of everything.

Open a terminal window (“File → Open” and then “New → Terminal”) and then you can use linux commands:

$ python -V
Python 3.7.6
$ pip --version
pip 21.1.1 from /opt/conda/lib/python3.7/site-packages/pip (python 3.7)
$ conda --version
conda 4.8.2
$ pip freeze > c4_w1_a2_freeze.txt
$ grep tensor c4_w1_a2_freeze.txt
tensorboard==2.5.0
tensorboard-data-server==0.6.0
tensorboard-plugin-wit==1.8.0
tensorflow==2.3.0
tensorflow-estimator==2.3.0

So you can see the versions of python and the various tools. The most important thing there is the output of “pip freeze”, which lists the versions of all the packages installed. I did this specifically for the “Application” assignment in Week 1 of ConvNets. I double checked the U-Net notebook in Week 3 of ConvNets and notice that it has an older version of python and does not include “conda” in the Docker image. Sigh. But I think the absence of conda is ok: the point is that we don’t really need to create the conda environment in the notebook, but just use the output of “pip freeze” to duplicate it locally.

Then you’ll need to find that “freeze” file whereever it is in your Docker file system and then download it. If you just open the terminal as I did and don’t “cd” anywhere, then you’re at least two levels of directory hierarchy above the notebook and associated data files.

Download the “pip freeze” file to your local system. Then create a new “conda environment” for your notebooks and then activate it (obviously you can pick whatever name you like in place of ConvNetRefresh):

conda create --name ConvNetRefresh python=3.7.6
conda activate ConvNetRefresh

Now you can install the various packages into that new “conda environment” based on the contents of the “freeze” file:

pip install -r c4_w1_a2_freeze.txt

What you will probably find is that you get a bunch of errors from doing that. I haven’t tried this in a couple of years, so I am working through trying to debug this process. One thing you probably need to do is remove all references to “conda” in the “freeze” file:

grep -v conda c4_w1_a2_freeze.txt > freeze_list.txt

But even doing that did not fix all the problems for me. It looks like the “pip” config treats some packages differently, including “numpy”. I’m still working on it, but this is not really buying me anything at this point, so I’m not sure how much more time I want to spend on this.

Please realize that the question you are asking is beyond the scope of this course. Also please realize that the mentors are volunteers: we are not paid to do this. That means we don’t work for you and are not required to answer any particular question even if it actually is about the course materials. One other thing to note is that I do not have access to a Windows system, so I can’t help you if you are trying to get this to work on Windows.

Since this is all a Public Service here, you can actually contribute to the effort by letting us know what else you discover in the process of getting this to work. In other words, it’s a two way street :nerd_face:.

1 Like