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.
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.
Then, you can find your Jupyter Notebook that has Anaconda. Have a fun coding with Jupyter Notebook!
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. Then, you can find your Jupyter Notebook that has Anaconda. Have a fun coding with Jupyter Notebook!
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.
댓글
댓글 쓰기