远程深度学习新环境配置流程

✅ 远程深度学习新环境配置流程

1. 安装 Miniconda

前往 Miniconda官网 下载并安装适合你系统的 Miniconda 版本。

2. 配置国内源

pip 换源

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

conda 换源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2

3. 创建 Conda 环境

conda create -n jupyterlab python=3.13 -y
conda activate jupyterlab

4. 安装 Jupyter Lab

pip install jupyterlab
jupyter-lab --generate-config

5. 配置远程访问

修改 ~/.jupyter/jupyter_lab_config.py 文件,加入:

c.ServerApp.ip = '0.0.0.0'
c.ServerApp.open_browser = False
c.ServerApp.port = 8899
c.ServerApp.allow_remote_access = True

6. 设置密码(推荐)

from jupyter_server.auth import passwd; print(passwd())

将生成的 hash 写入配置文件:

c.ServerApp.password = 'argon2:...'

7. pip 包定制安装路径

#!/bin/bash

PYTHON_VERSION=3.13
ENV_NAME=jupyterlab
CUSTOM_PATH="$HOME/miniconda3/python_packages/python${PYTHON_VERSION}"
SITE_PACKAGES_PATH="$HOME/miniconda3/envs/${ENV_NAME}/lib/python${PYTHON_VERSION}/site-packages"
PIP_CONF_PATH="$HOME/miniconda3/envs/${ENV_NAME}/.pip/pip.conf"
PTH_FILE="${SITE_PACKAGES_PATH}/custom_path.pth"

mkdir -p "$(dirname "$PIP_CONF_PATH")"
echo "[global]" > "$PIP_CONF_PATH"
echo "target = ${CUSTOM_PATH}" >> "$PIP_CONF_PATH"

mkdir -p "$CUSTOM_PATH"
mkdir -p "$SITE_PACKAGES_PATH"
echo "$CUSTOM_PATH" > "$PTH_FILE"

python${PYTHON_VERSION} -m pip install requests
python${PYTHON_VERSION} -c "import requests; print('✅ 成功导入 requests:', requests.__version__)"

8. 启动 Jupyter Lab

jupyter lab

然后访问 http://<服务器IP>:8899

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值