CONDA常用指令及测试pytorch是否安装成功

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,或者加大内存。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值