conda info --envs #查看现有环境
conda remove -n 环境名 --all # 删除环境
conda create -n hsnet python=3.7 # 创建 环境
conda create -n BBB --clone AAA # copy环境
测试pytorch 是否安装成功代码
import torch
print(torch.__version__)
print(torch.cuda.is_available())
x = torch.randn(1)
if torch.cuda.is_available():
device = torch.device("cuda")
y = torch.ones_like(x, device=device)
x = x.to(device)
z = x + y
print(z)
print(z.to("cpu", torch.double))
安装tensorflow及 tensorboardX conda install -c conda-forge tensorflow pip3 install tensorboardX
查看安装源
conda config --show-sources
添加安装源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
删除安装源
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
或者直接参考anaconda | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
anaconda镜像_anaconda下载地址_anaconda安装教程-阿里巴巴开源镜像站
如果下载pytorch一直不成功,可以试试修改.condarc文件,在channels中添加一行 ssl_verify:false 试试
channels:
- defaults
show_channel_urls: true
ssl_verify: false
监控GPU状态
watch -n 1 nvidia-smi
conda 安装离线包
conda install --use-local
pip 临时换源
-i https://pypi.tuna.tsinghua.edu.cn/simple some-package
如果遇到 RuntimeError: DataLoader worker (pid 27097) is killed by signal: Killed.
是因为内存给小了,原来内存也是会影响DataLoader的,需要调小num_workers,或者加大内存。