centos7 安装nnDetection环境

nnunet和nnDetection更新导致默认安装可能会出现无法调用GPU的问题,这里稍微细致的记录下安装nnDetection环境过程。

1.创建虚拟环境:

Please note that nndetection requires Python 3.8+. Please use PyTorch 1.X version for now and not 2.0

这里要求python3.8版本以上,pytorch1.0以上但不到2.0。综合考虑我选择python3.9:

conda create --name xxx python==3.9

2.在虚拟环境中安装pytroch。

Install CUDA (>10.1) and cudnn (make sure to select compatible versions!)

这里要求CUDA(>10.1)并且选择对应的cudnn。由于之前已经安装CUDA我先查看下本机CUDA版本:

(xxxxxxx) [xxxx@xxxxxxxxx ~]$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Tue_Sep_15_19:10:02_PDT_2020
Cuda compilation tools, release 11.1, V11.1.74
Build cuda_11.1.TC455_06.29069683_0

满足要求的。

[Optional] Depending on your GPU you might need to set TORCH_CUDA_ARCH_LIST, check compute capabilit。

可选项,查看GPU的计算能力没有需求。

Install torch (make sure to match the pytorch and CUDA versions!) (requires pytorch >1.10+) and torchvision(make sure to match the versions!).

这里进一步将pytorch版本要求提升到pytoch1.10以上,并且要匹配CUDA版本。去官网查看发现只右有如下这条满足:

则安装这个版本的pytorch:

Collecting torch==1.10.0+cu111Downloading https://download.pytorch.org/whl/cu111/torch-1.10.0%2Bcu111-cp39-cp39-linux_x86_64.whl (2137.6 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸━━━━━ 1.8/2.1 GB 6.4 kB/s eta 12:30:51
ERROR: Wheel 'torch' located at /tmp/pip-unpack-zyhz8qfc/torch-1.10.0+cu111-cp39-cp39-linux_x86_64.whl is invalid.

下载是失败了。但好像这种下载方式自带cu111了,那么我么是否可以下载自带cu102的版本呢。(不考虑cu12主要原因是本机nvidia驱动为NVIDIA-SMI 450.57       Driver Version: 450.57       CUDA Version: 11.0 )下面开始尝试:

则安装这个版本的pytroch:

(xxxxxxx) [xxxx@xxxxxxxxx ~]$ pip install torch==1.12.1+cu102 torchvision==0.13.1+cu102 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu102
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu102
Collecting torch==1.12.1+cu102Downloading https://download.pytorch.org/whl/cu102/torch-1.12.1%2Bcu102-cp39-cp39-linux_x86_64.whl (776.4 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 776.4/776.4 MB 1.3 MB/s eta 0:00:00
Collecting torchvision==0.13.1+cu102Downloading https://download.pytorch.org/whl/cu102/torchvision-0.13.1%2Bcu102-cp39-cp39-linux_x86_64.whl (19.1 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 19.1/19.1 MB 1.5 MB/s eta 0:00:00
Collecting torchaudio==0.12.1Downloading https://download.pytorch.org/whl/cu102/torchaudio-0.12.1%2Bcu102-cp39-cp39-linux_x86_64.whl (3.7 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.7/3.7 MB 1.3 MB/s eta 0:00:00
Collecting typing-extensions (from torch==1.12.1+cu102)Downloading typing_extensions-4.9.0-py3-none-any.whl.metadata (3.0 kB)
Collecting numpy (from torchvision==0.13.1+cu102)Using cached numpy-1.26.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)
Collecting requests (from torchvision==0.13.1+cu102)Using cached requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Collecting pillow!=8.3.*,>=5.3.0 (from torchvision==0.13.1+cu102)Using cached Pillow-10.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (9.5 kB)
Collecting charset-normalizer<4,>=2 (from requests->torchvision==0.13.1+cu102)Using cached charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (33 kB)
Collecting idna<4,>=2.5 (from requests->torchvision==0.13.1+cu102)Using cached idna-3.6-py3-none-any.whl.metadata (9.9 kB)
Collecting urllib3<3,>=1.21.1 (from requests->torchvision==0.13.1+cu102)Using cached urllib3-2.1.0-py3-none-any.whl.metadata (6.4 kB)
Collecting certifi>=2017.4.17 (from requests->torchvision==0.13.1+cu102)Using cached certifi-2023.11.17-py3-none-any.whl.metadata (2.2 kB)
Using cached Pillow-10.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.5 MB)
Using cached numpy-1.26.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB)
Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Downloading typing_extensions-4.9.0-py3-none-any.whl (32 kB)
Using cached certifi-2023.11.17-py3-none-any.whl (162 kB)
Using cached charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142 kB)
Using cached idna-3.6-py3-none-any.whl (61 kB)
Using cached urllib3-2.1.0-py3-none-any.whl (104 kB)
Installing collected packages: urllib3, typing-extensions, pillow, numpy, idna, charset-normalizer, certifi, torch, requests, torchvision, torchaudio
Successfully installed certifi-2023.11.17 charset-normalizer-3.3.2 idna-3.6 numpy-1.26.2 pillow-10.1.0 requests-2.31.0 torch-1.12.1+cu102 torchaudio-0.12.1+cu102 torchvision-0.13.1+cu102 typing-extensions-4.9.0 urllib3-2.1.0

安装成功pytroch1.12.1.下面尝试这个版本cuda是否可用:

Python 3.9.0 (default, Nov 15 2020, 14:28:56) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
True

如上所示可用,看来服务器没安装cuda可以在下载torch是可自带编译好的对应cuda版本来替代(不过可能还需要低于驱动显示的CUDA Version: 11.0 版本)

3.安装nndet框架

Clone nnDetection, cd [path_to_repo] and pip install -e .

(lungdoc) [pacs@localhost ~]$ git clone https://github.com/MIC-DKFZ/nnDetection.git
正克隆到 'nnDetection'...
remote: Enumerating objects: 1449, done.
remote: Counting objects: 100% (154/154), done.
remote: Compressing objects: 100% (65/65), done.
remote: Total 1449 (delta 119), reused 89 (delta 89), pack-reused 1295
接收对象中: 100% (1449/1449), 1.29 MiB | 1.72 MiB/s, done.
处理 delta 中: 100% (848/848), done.
(lungdoc) [pacs@localhost ~]$ cd nnDetection
(lungdoc) [pacs@localhost nnDetection]$ pip install -e .
Obtaining file:///home/pacs/nnDetectionPreparing metadata (setup.py) ... done
...........................................RuntimeError:The detected CUDA version (11.1) mismatches the version that was used to compilePyTorch (10.2). Please make sure to use the same CUDA versions.[end of output]note: This error originates from a subprocess, and is likely not a problem with pip.

其它安装库都没啥问题,但是在编译nms.cu时用到了安装在本地cuda版本。

为了不返工,我这里就在本机安装cuda10.2版本(虚拟环境中cu102应该值局限与可执行调用,要现场编译就不行了)下子cuda10.2和对应cudnn库。(本机上有安装包这里就不下载了)再次执行

还是报错无语了,再次查看其它系统老环境pytorch1.9.1,cuda11.1。 

再次卸载pytroch

torch                   1.12.1+cu102
torchaudio              0.12.1+cu102
torchvision             0.13.1+cu102

安装

torch                   1.12.1
再次编译还是报原来的错误如下图:

根据报错找到【BUG】关于Pytoch中CUDA扩展的本地安装 - 知乎这个攻略尝试下

##就是报了torch api中cloneable.h文件的错误,经过尝试,将cloneable.h文件中46行,58行,70行三句copy->parameters_.size() == parameters_.size()copy->buffers_.size() == buffers_.size()copy->children_.size() == children_.size()
##分别改成copy->parameters_.size() == this -> parameters_.size()copy->buffers_.size() == this -> buffers_.size()copy->children_.size() == this -> children_.size()
##保存后再次安装成功。

大佬牛啊,评论区大佬指出是有gcc版本过低导致的。本机gcc5.4也会报这个错。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/265826.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

首次发布亚马逊云科技生成式AI技术堆栈,re:Invent大会重磅发布

亚马逊云科技总是在不断重构&#xff0c;以推动创新&#xff0c;而今年re:Invent的主角毫无疑问是生成式AI。这从亚马逊云科技副总裁、首席布道师Jeff Barr在re:Invent 2023之前就迫不及待地写了一篇关于PartyRock的体验试玩教程即可窥见一斑。 事实也确实如此。在Las Vegas&am…

【从零认识ECS云服务器 | 快速上线个人网站】二、使用ECS云服务器

2.1 获取ECS 方式一&#xff1a;通过试用中心免费领取ECS实例 满足以下全部条件的阿里云用户&#xff0c;可免费试用云服务器ECS&#xff1a; 阿里云注册会员用户并完成阿里云企业认证或个人认证用户。申请用户是云服务器ECS产品的新用户&#xff0c;可以申请获得某一规格EC…

redis集群(cluster)笔记

1. 定义&#xff1a; 由于数据量过大&#xff0c;单个Master复制集难以承担&#xff0c;因此需要对多个复制集进行集群&#xff0c;形成水平扩展每个复制集只负责存储整个数据集的一部分&#xff0c;这就是Redis的集群&#xff0c;其作用是提供在多个Redis节点间共享数据的程序…

upload-labs

01 随便上传个文件 发现对于上传类型有限制 查看页面代码发现是js的过滤直接关闭js 上传成功 右键图片在新建标签页打开文件 这里直接抓包改名字也行 02 抓包修改后缀名 03 发现后端做了检测抓包修改失败 大小写绕过失败&#xff0c;php特性php1等会被当成php执行 这里图片的…

android bitmap保存本地背景是黑色的 解决方法

前言 最近在项目种有个电子签名功能 需要客户手写签名 然后保存本地 上传云端 //获取bitmapBitmap bitmapFromView mSignatureView.getBitmapFromView();BitmapUtil.saveImageToGallery(this, bitmapFromView);压缩为JPEG格式 saveImageToGallery 方法我做了修改 之前用的Bit…

STM32-定时器输入捕获

目录 一、输入捕获简介 二、频率测量方法 三、输入捕获框图 四、输入捕获通道 五、输入捕获基本结构 六、PWMI基本结构 七、开发步骤 八、输入捕获库函数 九、实验 9.1 输入捕获测频率 9.2 PWMI模式测频率和占空比 一、输入捕获简介 >IC&#xff08;Input Capture&…

GD32F30X-RT-Thread学习-线程管理

1. 软硬件平台 GD32F307E-START Board开发板MDK-ARM Keil 2.RT-Thread Nano 3.RT-Thread 内核学习-线程管理 ​ 在多线程操作系统中&#xff0c;可以把一个复杂的应用分解成多个小的、可调度的、序列化的程序单元&#xff0c;当合理地划分任务并正确地执行时&#xff0c;这…

计算机网络(三) | 数据链路层 PPP协议、广播CSMA/CD协议、集线器、交换器、扩展and高速以太网

文章目录 1 数据链路基本概念和问题1.1 基本概念1.2 基本问题&#xff08;1&#xff09;封装成帧&#xff08;2&#xff09;透明传输&#xff08;3&#xff09;差错控制 2.数据链路层协议2.1 点对点 PPP协议2.1.1 需要实现的2.1.2 PPP组成2.1.3 帧格式2.1.4 工作流程 2.2 广播 …

tamcat乱码

学习springmvc时tamcat乱码 ①、启动时tomcat控制台乱码 解决方法是&#xff1a;1、先把idea设置里的默认字节码改成utf-8 ​ 2、把idea显示编码改成utf-8&#xff0c;在末尾加上&#xff08; -Dfile.encodingUTF-8&#xff09; ​ 3、最后重启idea 加上这个 -Dfile.encodingU…

基于Java swing的医院信息管理系统(Java毕业设计)

大家好&#xff0c;我是DeBug&#xff0c;很高兴你能来阅读&#xff01;作为一名热爱编程的程序员&#xff0c;我希望通过这些教学笔记与大家分享我的编程经验和知识。在这里&#xff0c;我将会结合实际项目经验&#xff0c;分享编程技巧、最佳实践以及解决问题的方法。无论你是…

ffmpeg过滤器filter理论与实战

文章目录 前言一、DirectShow1、简介2、程序基本结构3、架构 二、过滤器1、视频过滤器 -vf2、音频过滤器 -af3、过滤器链&#xff08;Filterchain&#xff09;4、过滤器图&#xff08;Filtergraph&#xff09;①、基本语法②、Filtergraph 的分类 5、结构体间的关系图 三、过滤…

论文怎么改才能降低重复率

一、引言&#xff1a;智能工具助力&#xff0c;轻松降低论文重复率 论文的重复率是学术写作中的重要问题&#xff0c;如何有效降低重复率成为了许多研究者的关注焦点。如今&#xff0c;智能工具的发展为我们提供了更多选择。本文将介绍几种实用的智能工具&#xff0c;包括快码…