Ubuntu安装pytorch和mmdetection

本文档详细介绍了如何在conda环境中新建并配置PyTorch,以及安装mmcv和mmdetection。首先创建一个conda环境,安装pytorch 1.8.0、torchvision和torchaudio。接着,安装mmcv-full,根据pytorch版本选择合适的url。然后,通过git clone获取mmdetection源码,并完成安装。如果服务器无法访问外网,可将文件下载到本地后再上传。最后,通过运行`python tools/train.py -h`进行测试,确保环境配置成功。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.首先新建conda虚拟环境,安装pytorch

mmdetection不推荐1.11.0版本的torch

pytorch官方中torch历史版本:https://pytorch.org/get-started/previous-versions/

conda create -n mmdet python=3.7

查看conda环境

conda info --env

在这里插入图片描述
安装pytorch

conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge

2.安装mmcv-full

mmdetection中文文档:
https://mmdetection.readthedocs.io/zh_CN

pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html

这里的cu_version和torch_version是根据自己版本而定的,不清楚的可以看下面这个网址:
https://gitee.com/cubone/mmcv
根据上面安装的pytorch版本,我的mmcv-full安装指令如下:

pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.8.0/index.html

3.下载、编译、安装mmdetection

首先,安装git

conda install git

安装mmdetection

git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements/build.txt
pip install -v -e .  # or "python setup.py develop"

若服务器不能翻墙,就从本机上下载后传到服务器即可

4.测试

python tools/train.py -h

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值