AutoDL中Jupyterlab终端创建虚拟环境及遇到的问题

创建虚拟环境

使用conda -V查看版本

root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# conda -V
conda 4.10.3

使用conda env list查看虚拟环境列表

root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# conda env list
# conda environments:
#
base                  *  /root/miniconda3

使用conda create -n 环境名 python=x.x创建虚拟环境

root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# conda create -n wasser python=3.10
# To activate this environment, use
#
#     $ conda activate wasser
#
# To deactivate an active environment, use
#
#     $ conda deactivate

激活虚拟环境:遇到问题

输入conda activate 环境名 遇到报错:

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run

    $ conda init <SHELL_NAME>

IMPORTANT: You may need to close and restart your shell after running 'conda init'.

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.

解决方法:先输入source activate,再进行激活环境:conda activate+环境名

root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# source activate
(base) root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# conda activate wasser
(wasser) root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# torch
bash: torch: command not found
(wasser) root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# 

配置虚拟环境

查看cuda版本:nvcc --version或者nvidia-smi

(wasser) root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Mon_May__3_19:15:13_PDT_2021
Cuda compilation tools, release 11.3, V11.3.109
Build cuda_11.3.r11.3/compiler.29920130_0

去pytorch官网找到对应的torch版本,进行下载

wasser) root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113

  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值