기본 콘텐츠로 건너뛰기

Running Anaconda Python on Jupyter Notebook with Docker in Windows

I think there is no IDE more suitable for studying machine learning or deep learning with Python than Jupyter Notebook. However, it is so difficult to construct a Jupyter environment without crushing with the existing Python environment. So, I decided to make an only-for-deep-learning environment in the Ubuntu Docker container to avoid all annoyance. I will assume that you already installed Docker.

Environment

  • Ubuntu 17.04 LTS
  • Anaconda 5.0.0 (containing Python 3.6)

Creating Docker Container

First of all, we are going to create a Docker container.
The world is going better day after day! You can get a Docker image containing Anaconda that someone created and simultaneously make a container with the image you just downloaded just with this one-line command.
docker run -it --name jupyter -p 8000:8000 --volume /c/Users/jinai/Dropbox/HaveToLearnToRun/CSE/3_1_MachineLearning/jupyter_workspace:/root/jupyter_workspace continuumio/anaconda3 /bin/bash
It’s quite complex. So let me explain you about options.
  • -it : It’s combination of i option and t option.
    • -i : Interactive. This option makes ouput of the commands visible.
    • -t : tty. It provides terminal environment.
  • –name : alias of the container. You can start/stop/remove the container with this name.
  • -p : port. You can connect to the container with this port. First one is port of the Docker host, and second one is of Docker container. // is of Docker OS 말 되나 모르겠네…
  • –volume : You can share directory of the outer OS with the Docker container. The format of directory of the outer OS should be the format of Linux, even if it is Windows. In addition you should be care of using and not using capital letters.
  • continuumio/anaconda3 : It’s the image file that someone made and uploaded. It contains Anaconda3.
  • /bin/bash : It means you will use bash every time you start the container you just made.

Start Jupyter Notebook

And then you just have to type this to start Jupyter Notebook.
jupyter notebook --ip=0.0.0.0 --port=8000 --allow-root
Congraturations! Your Jupyter Notebook is now turned on.

Use Jupyter Notebook

So, where is our Jupyter Notebook? You may be seeing a black screen that tells you Notebook is running but there is no text editor or anything that seems like IDE. What you should do is turning on a web browser, and put this on the address bar.
http://192.168.99.100:8000/?token=[token_value]
You can find your token_value in here.
jupyter_token_in_Docker
Then, you can find your Jupyter Notebook that has Anaconda. Have a fun coding with Jupyter Notebook!
jupyter_anaconda_test

Automation

You can run jupyter notebook without wrting this long command by creating a compiled C file and register it as an alias.

Ready

Get vim and gcc.
~# apt-get install vim -y
~# apt-git install gcc -y

Creating C file

Go to home directory(~).
~# vim run_jupyter.c
#include <stdio.h>
#include <stdlib.h>

int main() {
    system("clear");
    system("jupyter notebook --ip=0.0.0.0 --port=8000 --allow-root");
    return 0;
}

Compile C file and make an object file

~# gcc -o run_jupyter run_jupyter.c

Register the object file as an alias

Open ~/.bashrc file and add this line.
alias rj='cd ~/jupyter_workspace; ~/run_jupyter'
And run this command.
source .bashrc
Now, you can run jupyter notebook by putting ‘rj’ in any directory.

댓글

이 블로그의 인기 게시물

The reason why I selected Google Blogger

In SW Maestro, 3 mentors for our team are fixed, and we got our first official mentoring from mentor 배권한. He gave us an assignment - make a personal blog and post an article about co-working tools. He insisted we run a blog for 4 reasons. We forget what we have studied someday We can realize something new when we think about it again Somebody like a headhunter may contact me through my blog To make my activities visible So, I decided to make a post about pros and cons of famous blog services. Criteria of Selection I consider these factors. Main Factors It should 'work' well. It should be easy to parse my posts from the blog. It should be easy to write code on my blog. It must take responsive design, so that it can be seen with mobile device. It must be easy to be exposed by Google search. It must provide reply function. Sub Factors It is good if the design is fine. It is good if the markdown function is...

Neural Network [cs231n - week 3 : Loss Functions and Optimization]

The purpose of this post is to summarize the content of cs231n lecture for me, so it could be a little bit unkind for people who didn’t watch the video . In addition, I omitted some contents that I don’t think it’s important enough, so use this article as just an assistance. Loss Function Below is the general numerical expression of loss functions. Multiclass SVM Loss There are many many many kinds of loss functions, but this class only deals with two of them : SVM loss and softmax . Above is the expression of SVM loss function. Meaning of the expression is, that score of the correct class should be larger at least one comparing to scores of the others to make the loss zero. It is more easier to understand it with an example. First, get each loss of the class like the image above. I'm not omitting the explanation because it's annoying to write. It's because explanation of the lecture slide is kind enough. And then, get the loss by calculating the mean va...