I am using Windows and learning to use tensorflow, so I need to run it under Docker (Toolbox).
Following the usual instruction:
$ docker run -it gcr.io/tensorflow/tensorflow
I can launch a Jupyter notebook on my browser at 192.168.99.100:8888
and run the tutorial notebooks without problems.
Now when I try to import pandas as pd
, which is installed in my computer with pip, on Juypter it just said ImportError: No module named pandas
Any idea how I can get this library to work inside the tensorflow images launched from docker?
Screenshot
Pandas is usually imported under the pd alias. alias: In Python alias are an alternate name for referring to the same thing. Now the Pandas package can be referred to as pd instead of pandas .
Enter the command “pip install pandas” on the terminal. This should launch the pip installer. The required files will be downloaded, and Pandas will be ready to run on your computer. After the installation is complete, you will be able to use Pandas in your Python programs.
You need nvidia-docker to run them. NOTE: GPU versions of TensorFlow 1.13 and above (this includes the latest- tags) require an NVidia driver that supports CUDA 10. See NVidia's support matrix. -jupyter tags include Jupyter and some TensorFlow tutorial notebooks..
The Docker image
should be built on a linux
operating system. You should launch a shell
inside the Docker image
grc.io/tensorflow/tensorflow
to install the requisite python dependencies.
See Docker quickstart for using
docker run -it grc.io/tensorflow/tensorflow /bin/bash
and then
sudo apt-get install python-pandas
according to pandas docs.
To avoid doing this every time you launch the image, you need to commit
the change to create a new image
.
To commit
the change, you need to get the container
id
(after run
and installation steps above):
sudo docker ps –a # Get list of all containers previously started with run command
Then, commit
your changes git
style using the container_id
displayed in the container list you just got and giving it an image_name
of your choosing:
sudo docker commit container_id image_name
The new image
will now show up in the list displayed by sudo docker ps –a
.
If you get a free docker
account you can push
and pull
your updated image
to your docker
repo
, or just keep it locally.
See docs under 'Updating and Committing your image'.
For windows users:
docker run -d -p 8888:8888 -v /c/Users/YOUR_WIN_FOLDER:/home/ds/notebooks gcr.io/tensorflow/tensorflow
Then use the following command to see the name of your container for easy execution commands later on (the last column will be the name):
docker ps
Then run:
docker exec <NAME OF CONTAINER> apt-get update
And finally to install pandas:
docker exec <NAME OF CONTAINER> apt-get install -y python-pandas
(the -y is an automatic 'yes' to stop a prompt from appearing for you to agree to the installation taking up additional disk space)
Here is an image with the pandas installed -
https://hub.docker.com/r/zavolokas/tensorflow-udacity/
Or pull it docker pull zavolokas/tensorflow-udacity:pandas
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With