跳转至

服务器使用

本地使用远程服务器 jupyter notebook

服务器端

安装notebook

pip install jupyter notebook  # 安装jupyter notebook

如果我们想把自己创建的虚拟环境(如torch11 )写入jupter中,可以这样操作:

conda install nb_conda  # 为Jupyter Notebook配置虚拟环境
conda install ipykernel  # 为Jupyter Notebook配置虚拟环境
python -m ipykernel install --user --name torch11 

启动 jupyter notebook

jupyter notebook --no-browser

注:复制倒数第二行的 token,这个 token 就是远程访问的密码,同时记下端口号8888。

本地PC端

在 PC 端做一个端口映射,即通过 ssh 隧道来将服务器端的8888端口号映射到本地(PC端)的某个端口(如1234):

ssh -L 1234:localhost:8888 username@xxx.xxx.xxx.xxx

直接访问http://localhost:1234

服务器下载huggingface模型

使用huggingface官网提供的huggingface-cli工具

pip install -U huggingface_hub
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download --resume-download gpt2 --local-dir gpt2