TensorFlow docker dev workflow on mac - macos

There is an official guide on how to install it that doesn't say much about actually developing in it.
From what I understand, there is a quite big challenge in developing with Docker in general. Not to mention there could be deeper technical complications about going with it for TensorFlow, maybe mostly thanks to GPUs. So there is a lot of stuff to after pulling the docker image...
Does anyone have a step by step guide on how to get development going here?

You could mount a local directory to the docker container so that you can still use your preferred editor in osx. Here's a command to start the container with a mounted directory and run a command:
docker run --name tensorflow --rm -v /Users/me/Code/web/tensorflow_dev:/tensorflow_dev b.gcr.io/tensorflow/tensorflow /bin/sh -c 'cd /tensorflow_dev && python mnist.py'
-v will mount the local directory and the -c will run the specified command. So your flow might look like:
Edit python script in your favorite editor
Run the above command to excute your script
However, I actually use pycharm so that I can place breakpoints and run the python script interactively within the editor.
Hope this helps.

Related

Docker compose V2: unknown shorthand flag 'f' (windows)

I'm currently running docker desktop version 20.10.22 (build 3a2c30b, fresh install) on Windows (using wsl2), but docker compose commands with the -f flag do not work correctly. Since I'm using docker compose V2 (checked the option in the docker desktop settings), my commands are with a space instead of a hyphen. I get the following message when running any docker compose command using -f:
unknown shorthand flag: 'f' in -f See 'docker --help'.
Specifically, I'm running the FIWARE NGSI-LD tutorials. All docker compose commands that are used within those tutorials fail. The commands can be found in the services file for each tutorial. For example, a command that fails (saying that the -f flag does not exist) within the Short-Term-History tutorial is the following:
docker compose -f docker-compose/mintaka.yml -p fiware up -d --remove-orphans --renew-anon-volumes
The weird thing is that docker compose --help and docker compose --version both return the output from respectively docker --help and docker --version, as if it excludes the compose keyword. The output of the above command also refers to the standard docker help command instead of the docker compose help.
UPDATE: Docker excludes the compose keyword between docker and the rest of the command. Replacing compose with a random string of letters gives the same effect. It seems as if it cannot recognize the compose keyword.
The old docker-compose is not installed so that does not work either. Running which docker-compose returns the docker-compose.exe location, inside the .../Docker/resources/bin folder. Running which docker compose returns the location of docker.exe. The .../Docker/resources/bin folder is inside the path environment variable.
Does anybody know what the problem might be? I've searched countless websites but did not find any solutions for this problem yet.
Kind regards
Here is what I have in running processes when I run docker compose events:
Please check if you have all these directories and files. Then we can troubleshoot further.
I reinstalled docker desktop with the same installer (also same version) and this resolved the problem weirdly enough...
The only difference between my old and new installation was that I already had wsl2 installed this time.

What's the default location for Zeppelin notebooks in the Windows file system?

On a fresh Win10 machine with fresh docker, the following command instantiates Zeppelin:
docker run -p 8080:8080 --rm --name zeppelin apache/zeppelin:0.8.1
... allowing me to create a new notebook using the GUI at http://localhost:8080/#/
... but where are these notebooks stored? What's the default path to their directory so that I can git init and get to work? With Jupyter there is a 'tree' showing clearly the location/path of all notebooks; I don't see one for Zep and an hour's Googling has not been informative.
The GUI's 'Notebook Repos' button doesn't seem to help:
With the help of this answer I've been able to view the specific .json file representing my notebook. This answers the Q of where zeppelin notebooks exist in Docker images; leaving unanswered the question of where they exist in the Windows filesystem when NOT using Docker.
If using Docker (as recommended by the Zeppelin docs) this is the recipe for finding a notebook file:
# first steps are taken in Powershell
docker ps # displays an image id for use in next line
docker commit <image_id_here> mysnapshot
docker run -t -i mysnapshot /bin/bash
# now in bash inside the Docker image
root#91f4bf850583:/zeppelin# ll notebook/2E6D1WBGT/note.json
... so (if using Docker) the best way to version-control a notebook is by using Docker versioning. This is quite different to Jupyter's approach where one can run individual .ipynb notebooks locally and version-control each of them. Having answered my own question I feel greatly more informed about Docker and the differences between Jupyter vs Zeppelin. Very curious to know if anyone can solve the original question of where notebooks are stored if running in Windows WITHOUT Docker 🙏

Is it possible to install CNTK on a macbook?

It is possible to install Microsoft CNTK on a macbook? I have OS X El Capitan. The official Microsoft documentation at https://github.com/Microsoft/CNTK/wiki/Setup-CNTK-on-your-machine doesn't provide any information for mac users.
Thank you
As of June 2017, you can only run CNTK on OSX using Docker (which will run a Linux container)
Documentation from Microsoft is available here: https://learn.microsoft.com/en-us/cognitive-toolkit/CNTK-Docker-Containers
If you want to run the CPU version of CNTK (as opposed to a GPU enabled) you'll need to pull a particular version of the docker container. See: https://hub.docker.com/r/microsoft/cntk/
I recommend using the following for CPU CNTK:
docker pull microsoft/cntk:2.0-cpu-python3.5
Once you've pulled the container above, you can use Jupyter Notebooks to look at tutorials etc:
First, run the container:
docker run -d -p 8888:8888 --name cntk-jupyter-notebooks -t microsoft/cntk:2.0-cpu-python3.5
Then run this command:
docker exec -it cntk-jupyter-notebooks bash -c "source /cntk/activate-cntk && jupyter-notebook --no-browser --port=8888 --ip=0.0.0.0 --notebook-dir=/cntk/Tutorials --allow-root"
You'll want to access the shell to run CNTK commands. You can attach a bash shell using docker.
Get your container id
docker ps
Then attach a shell
docker exec -it <container_id> bash
While it might not be supported on Mac directly, you can always use a virtual machine to get around.
You can setup docker in your local environment.
https://docs.docker.com/docker-for-mac/
Follow its documentations on how to install on Docker
https://github.com/Microsoft/CNTK/wiki/CNTK-Docker-Containers
We currently support both Linux and Windows. Mac support is on our ToDo or would be interested in community contribution.
I'm currently building CNTK on a linux machine without root access, installing every dependency with linuxbrew (a fork of homebrew). So I think is possible to build on MacOS natively. You can try building it from source with CNTK linux manual to build from source. Let me know if you have any issue.

Installing OpenFOAM through Docker

I'm having a bad time trying to install OpenFOAM using Docker(on a MacOSX El Capitan). I've been following the official tutorial.
When I try to execute the first script (installOpenFOAM+), through the command line:
docker-machine ssh default $HOME/installOpenFOAM+ $HOME
I get the following result on the terminal screen:
machine does not exist
I've been looking for a solution online over and over but it seems nobody has had an issue like this. Has someone here faced the same problem?
Try making the install script executable before the first script, it seems to work for some people. That is, use
chmod +x installOpenFOAM+
I also had tough time installing Openfoam using docker.
After you install docker, you need to create a virtual machine (named default).
Once it is done, change the permission of install script. Then try to install it.
docker-machine create --driver virtualbox default
chmod a+x installMacOpenFOAM+
docker-machine ssh default $HOME/installMacOpenFOAM+ $HOME
I am not able to stat the application.

docker-compose run doesn't work in windows

I am trying to figure out development with django and postgresql while using windows as the host OS. I followed 2 tutorials and both of them want me to run commands using docker-compose run, but it doesn't work on windows. It says:
> docker-compose.exe run web django-admin.py startproject rolesweb .
←[31mERROR←[0m: Interactive mode is not yet supported on Windows.
Please pass the -d flag when using `docker-compose run`.
Is there an alternative to this command? What should I do to be able to follow the tutorials further?
The tutorials:
https://docs.docker.com/compose/django/
https://realpython.com/blog/python/django-development-with-docker-compose-and-machine/
An alternative is to run docker-compose through a container where docker-compose is installed. That is what I initially recommended. In that context, the -d option would be supported.
docker-compose itself depends on nodejs/node-gyp which does not work well on Windows.

Resources