Docker build for CPU and GPU
See original GitHub issueI have here added a Docker file for both CPU and GPU builds.
How To Build the Docker image
To build the Docker image for CPU only
git clone https://github.com/loretoparisi/generating-reviews-discovering-sentiment.git
cd generating-reviews-discovering-sentiment
docker build -t sentiment-neuron -f Dockerfile .
or execute ./build.sh
while to build the Docker image for GPU
cd generating-reviews-discovering-sentiment
docker build -t sentiment-neuron -f Dockerfile.gpu .
or you execute ./build.sh GPU
How To Run the Docker image
To run for CPU
cd generating-reviews-discovering-sentiment
docker run --rm -it sentiment-neuron bash
or execute ./run.sh
while to run for GPU you have to attach the nvidia-docker driver and device (here we attach the device 0, that is the first GPU as default):
docker run -it --device=/dev/nvidiactl --device=/dev/nvidia-uvm --device=/dev/nvidia0 --volume-driver nvidia-docker -v nvidia_driver_367.57:/usr/local/nvidia:ro $IMAGE $CMD
or execute ./run.sh GPU
How To Use it
As soon as you run the image you will be in the /sentiment
folder.
Then you can run the provided examples test_sentiment.py
:
root@718644c454d5:/sentiment# python test_sentiment.py
7.592 seconds to transform 8 examples
it was a nice day 0.012658
it was a great day 0.371533
it was a bad day -0.499269
It was a wonderful day 0.503395
It was an excellent day 0.44557
It was a super excellent day 0.623401
It was such a bad bad day -0.858701
It was such a bad bad bad day -1.04497
and the test_generative.py
example, adapted from this fork.
root@e713b094abb6:/sentiment# python test_generative.py
'I couldn't figure out'... --> (argmax sampling):
Positive sentiment (1 sentence):
I couldn't figure out how to use the stand and the stand but I love it and it is so easy to use.
Negative sentiment (+100 chars):
I couldn't figure out how to get the product to work and the company would not even try to resolve the problem. I would ...
'I couldn't figure out'... --> (weighted samples after each word):
Positive sentiment (3 examples, 2 sentences each):
(0) I couldn't figure out what was going on with the characters from page one. I was so engrossed in the story that I read all day.
(1) I couldn't figure out how to install the installation video that came with it but I am so glad I did. My son was so excited to put this together for me.
(2) I couldn't figure out what it was until finding this book by accident. Every time I encounter a book from this trilogy I enjoy it as much now as I did when I was a child.
Negative sentiment (3 examples, 2 sentences each):
(0) I couldn't figure out how to get the stupid thing to play youtube videos. I should have never bought this product.
...
Notes
- I had to merge the PR here to support the generative test that adds the
generate_sequence
method. - To enable the Nvidia GPU on the host machine, you need to have
nvidia-docker
installed. To check the nvidia toolkit installation please run thenvidia-smi
command to list the available connected gpu. - To address some python language compatibility issues, I’m using the
tensorflow
latest python3 docker image -tensorflow:latest-py3
andtensorflow:latest-gpu-py3
for the gpu. - I’m adding the
tqdm
module via pip in the Dockerfile.
If there will be further info how to train this model, I will add to the Docker image.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7
Top Results From Across the Web
Runtime options with Memory, CPUs, and GPUs
Runtime options with Memory, CPUs, and GPUs ... Docker provides ways to control how much memory, or CPU a container can use, setting...
Read more >A complete guide to building a Docker Image serving a ...
A complete step-by-step guide for building a Docker image (GPU or CPU) along with explaining all best practices that should be followed ...
Read more >How to containerize GPU-accelerated applications with ...
In this instalment of our DevOps consulting series, we look at how to build and run Docker containers using high-powered NVIDIA GPUs, providing ......
Read more >Using Your GPU in a Docker Container - Roboflow Blog
Certain things like the CPU drivers are pre-configured for you, but the GPU is not configured when you run a docker container.
Read more >Multi-CPU Architecture builds with Docker — Understanding ...
Docker brought a massive change and practical movement in the virtualization world. And it couldn't just be supported towards one operating ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@loretoparisi Thanks a bunch!
@loretoparisi Thanks a tonne. Very Helpful …!!