Conda

less than 1 minute read

Published:

A tutorial for conda

虚拟环境

  1. 查看当前存在哪些虚拟环境
    conda env listconda info --envs
  2. 创建虚拟环境
    conda create -n [EnvName] python=3.11.4
  3. 指定目录
    conda create --prefix=C:/Anaconda3/envs/xxx python=3.11.4
  4. 激活虚拟环境
    conda activate [gnnEnv]

安装包

  1. 基础工具
    conda install tqdm pandas numpy matplotlib
  2. Pytorch with cuda 12.1
    conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
  3. Pytorch with cpuonly
    conda install pytorch torchvision torchaudio cpuonly -c pytorch
  4. PyG
    conda install pyg -c pygpip install torch_geometric
  5. sklearn
    conda install scikit-learn

删除虚拟环境

  1. 退出环境
    conda deactivate
  2. 删除环境
    conda remove -n [EnvName] -all

其他

  1. 查看自动电脑是否安装cuda
    nvidia-smi
  2. pip错误
    ERROR: Could not find a version that satisfies the requirement xxxx(from versions: none)
    ERROR: No matching distribution found for xxxx
    直接选用pip源并且信任它的来源就可以解决这种问题。
    pip install 库包名 -i [http://pypi.douban.com/simple/](http://pypi.douban.com/simple/) --trusted-host [pypi.douban.com](http://pypi.douban.com/)
  3. 镜像源安装其它库
    pip install sklearn -i https://pypi.tuna.tsinghua.edu.cn/simple
    pip install pandas -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com/pypi/simple
  4. conda添加镜像源
    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/main/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ conda config --set show_channel_urls yes