服务器部署Jupyter Lab,配置远程访问及开机启动

安装Jupyter Lab

pip3 install jupyterlab

生成配置文件

jupyter lab --generate-config

在配置文件中追加下面内容

c.NotebookApp.allow_remote_access = True
c.NotebookApp.open_browser = False
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.port = 8888
c.NotebookApp.password = '加密密码字符串'

加密密码字符串可以通过Python命令获得

from jupyter_server.auth import passwd
passwd()

手动启动Jupyter Lab

jupyter lab

此时浏览器打开http://ip:8888/lab就可以了

接下来配置自动启动

vim /etc/systemd/system/jupyterlab.service

写入以下内容

[Unit]
Description=JupyterLab
After=network.target
 
[Service]
Type=simple
PIDFile=/run/jupyterlab.pid
ExecStart=/usr/local/bin/jupyter lab --allow-root
User=root
WorkingDirectory=/home
Restart=on-failure
RestartSec=5
 
[Install]
WantedBy=multi-user.target

接下来使开机启动生效

systemctl enable jupyterlab.service
systemctl start jupyterlab.service

查看启动结果

systemctl status jupyterlab.service

最后reboot一下,如果重启之后可以浏览器访问,就是成功了

参考文章:https://blog.csdn.net/weixin_53742691/article/details/138424057


服务器部署Jupyter Lab,配置远程访问及开机启动

让Windows的Linux子系统支持使用显卡算力

训练大模型,Windows有一些不便,为了不损失性能,使用Windows的Linux子系统来训练,但Linux子系统默认不能使用显卡,所以,需要提前配置一下。

1,检查Windows版本,必须是Windows10 21H2及更高(含Windows11)

2,安装显卡驱动(一般出厂就安装好了,刚刚重装完系统的,安装一下)

3,在“启用或关闭Windows功能”里面,启用“适用于 Linux 的 Windows 子系统”和“虚拟机平台”,或者PowerShell运行下面命令

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

4,下载Linux WSL2内核包并安装

https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

5,使用PowerShell将WLS2设置为默认版本

wsl --set-default-version 2

6,从Windows应用商店下载需要的Linux子系统并安装

7,查看显卡是否正常使用

nvidia-smi

如果在上述步骤之前已经安装了Linux子系统,需要先卸载再重新安装(我比较菜,没发现别的办法)

参考文章:https://huaweicloud.csdn.net/63563ce9d3efff3090b5bc6a.html


让Windows的Linux子系统支持使用显卡算力