Jupyter Notebook is an excellent development environment. On an Ubuntu server, start the service, develop in a browser, and execute.ipynb files visually, so you can execute deep learning algorithms directly on the GPU.

Environment:

  1. Log in to the server using LOCAL SSH -> Log in to the server using SSH.
  2. Access the Jypyter service on the Ubuntu server.

Key points:

  • Installation jupyter;
  • Set the jupyter access password.
  • Configure the JUPyter environment.
  • Access the JUPyter service through jumpers;
  • Add a virtual environment.

Start the service

Create A VirtualEnv and install Jupyter in the virtual environment.

pip install jupyter 
Copy the code

Create the key, the key is the password of jupyter login, generate sha1 encryption string:

>> from notebook.auth import passwd
>> passwd()
Enter password: 
Verify password: 
'sha1:xxx'
Copy the code

Edit the configuration file named jupyter_config.py

c.NotebookApp.ip = 'localhost' # specified
c.NotebookApp.open_browser = False # Turn off auto-open browser
c.NotebookApp.port = 8812 The port is specified arbitrarily
c.NotebookApp.password = u'sha1:xxxx' # copy the key generated in the previous step
Copy the code

To start the Jupyter service: Jupyter notebook –config=jupyter_config.py

(mlp3_p37_venv) xxx@xxxx:/data1/wcl/workspace$ jupyter notebook --config=jupyter_config.py

[I 17:14:01.262 NotebookApp] Serving notebooks from local directory: /data1/wcl/workspace
[I 17:14:01.262 NotebookApp] The Jupyter Notebook is running at:
[I 17:14:01.262 NotebookApp] http://localhost:8812/
[I 17:14:01.262 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Copy the code

Nohup startup commands:

nohup jupyter notebook --config=jupyter_config.py &
Copy the code

Local connection

SSH /config is used to connect to the server locally

Host gateway HostName xx.xx.xx.xxx User xxx Port xxxxx Host 3 User xxx HostName xxx.xx.xx.3 ProxyCommand ssh -q -W %h:%p  gatewayCopy the code

Run the following command:

  • -n: indicates that no command is to be executed remotely.
  • -f: indicates that SSH is executed in the background.
  • -l: specifies the configuration of port forwarding
ssh -N -f -L localhost:8812:localhost:8812 xxx@3
Copy the code

The preceding is the local port, the following is the remote port, XXX is the user name, 3 is the server.

This command can also be written to the system environment and is executed automatically every time the shell is started.

In the local browser, enter http://localhost:8812


Adding a Virtual Environment

In development, you need to use virtual environments, so you need to add virtual environments in Jypyter.

  1. Activate the virtual environment;
  2. Add to ipython kernel;

The command is as follows:

(mlp3_p37_venv) xxx@3:/data/workspace$ ipython kernel install --user --name=mlp3_p37_venv
Copy the code

Test Python version:


OK, that ‘s all!