AI开发平台ModelArts-将Notebook的Conda环境迁移到SFS磁盘:克隆原有的虚拟环境到SFS盘

时间:2025-01-26 10:50:48

克隆原有的虚拟环境到SFS盘

# shellconda create --prefix /home/ma-user/work/envs/user_conda/sfs-clone-env --clone PyTorch-1.8 -y
Source:      /home/ma-user/anaconda3/envs/PyTorch-1.8Destination: /home/ma-user/work/envs/user_conda/sfs-clone-envPackages: 20Files: 39687Preparing transaction: doneVerifying transaction: doneExecuting transaction: done## To activate this environment, use##     $ conda activate /home/ma-user/work/envs/user_conda/sfs-clone-env## To deactivate an active environment, use##     $ conda deactivate

查看新创建的clone虚拟环境,如果出现新创建的虚拟环境的名称为空的情况,可以参考添加新创建到虚拟环境到conda env

# shellconda env list
# conda environments:#base                     /home/ma-user/anaconda3PyTorch-1.8              /home/ma-user/anaconda3/envs/PyTorch-1.8python-3.7.10            /home/ma-user/anaconda3/envs/python-3.7.10sfs-clone-env            /home/ma-user/work/envs/user_conda/sfs-clone-envsfs-new-env           *  /home/ma-user/work/envs/user_conda/sfs-new-env

(可选)将新建的虚拟环境注册到JupyterLab kernel(可以在JupyterLab中直接使用虚拟环境)

# shellpip install ipykernelipython kernel install --user --name=sfs-clone-envrm -rf /home/ma-user/.local/share/jupyter/kernels/sfs-clone-env/logo-*

说明:此处“.local/share/jupyter/kernels/sfs-clone-env”为举例,请以用户实际的安装路径为准。

刷新JupyterLab页面,可以看到新的kernel。

support.huaweicloud.com/bestpractice-modelarts/modelarts_10_0141.html