Article Directory
Preface
I want to open jupyter on the server and open it in a local browser. This article is divided into two parts to introduce.
The first part is not helpful for solving the remote access server. It mainly introduces the installation of anaconda and the operation of replacing the jupyter kernel.
The second part mainly introduces how to realize jupyter remote access server(*).
Configure jupyter notebook
Step 1: install anaconda
1. Download the corresponding version of anaconda from the official website :
2. Drag the downloaded Anaconda3-2020.07-Linux-x86_64.sh file to your directory through WinSCP:
3. In Xshell, chmod 777 Anaconda3-2020.07-Linux-x86_64.sh
modify the running permissions of the file through commands ;
4. Then through ./Anaconda3-2020.07-Linux-x86_64.sh
to install anaconda;
5. After the installation is complete, reconnect to the server and (base) appears, which means success:
Step 2: Replace the jupyter notebook kernel
1. Use anaconda conda create -n 名称 python=版本
to create a virtual environment. Among them, the name is like: Keras\Pytorch, decide by yourself; the version is like: 3.7\3.8...
2. Pass conda activate 名称
to activate the environment (my virtual environment is called Keras):
If the creation fails, it appears:
Solution reference:
the ultimate solution to the CondaHTTPError problem when anaconda creates the environment
3. pip install --user ipykernel
Install ipykernel through
4. Pass python -m ipykernel install --user --name=XXXX
, add the current virtual environment to the kernel.
Among them, XXXX is the name you want the virtual environment to display in Jupyter's kernel:
Jupyter remote access server
(After the above operations are completed, remember to conda deactivate
exit to the base environment)
Then start:
1. By jupyter notebook --generate-config
generating configuration files
In this way, the configuration file jupyter_notebook_config.py is generated under ~/.jupyter/
2. Generate access password:
Type in the terminal python
, enter the python editing environment, and then set your own password. Be sure to remember the output out[2] of the last line. You will use it later:
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:xxxxxxxxxxxxxxxxx'
3. Through vim ~/.jupyter/jupyter_notebook_config.py, you can modify the configuration file just generated in the terminal:
c.NotebookApp.ip = ' * ' #允许所有的ip访问
c.NotebookApp.password = u 'sha: XXXXX' #这里粘贴上一步生成的密文
c.NotebookApp.open_browser = False #不自动打开浏览器
c.NotebookApp.port = 8989 #端口可随意命令(文档建议大于8000)
c.NotebookApp.allow_remote_access = True #
It is recommended to paste the above statement directly at the beginning:
Then pass :wq
, save and exit
4. Open jupyter notebook
The opening here is not to open in the virtual environment just created, but to exit to the base environment through conda deactivate, and then open through the jupyter notebook statement:
Then it produces the following:
Copy the address behind the mosaic, enter it into the local browser, and you're done
If you still can't log on, then modify the XXXX in http://XXXX:8989/, and change it to the ip address of the server, for example: 10.10.9.148, it will succeed:
Install pytorch
python=3.7
pip install --user torch==1.3.0+cu100 -f https://download.pytorch.org/whl/torch_stable.html
Reference
[1] Common commands of pip conda jupyter-myself
[2] jupyter remote access server-a tobey
[3] jupyter notebook connects to the remote server-yjinyyzyq
[4] local browser accesses the remote terminal jupyter notebook-small match _
[5] The ultimate solution to the CondaHTTPError problem when anaconda creates the environment-JJ1018RR
[6] Invincible brother