【机器学习】【ubuntu】MinkowskiEngine 安装

MinkowskiEngine 是进行稀疏卷积(sparse conv)的库,下面来介绍如何安装
github下载地址:https://github.com/NVIDIA/MinkowskiEngine
里面的安装步骤虽然已经比较详细,但还是有些小坑

这里以cuda10.2为例,首先确认服务器的cuda版本和cuda toolkit的版本都是10.2,否则参考这篇文章切换成正确的版本:服务器cuda toolkit多版本切换

在这里插入图片描述

  1. 安装g++ -7

坑一:安装失败,和版本切换失败
参考这篇文章:gcc/g++傻傻分不清?如何实现ubuntu多版本gcc/g++切换

  1. 下载MinkowskiEngine到服务器

坑二:git clone失败

一般情况,我们直接git clone就行

git clone https://github.com/NVIDIA/MinkowskiEngine.git

但是鉴于学校服务器有时上外网不是很方便,github本身在国内也老是连不上,那么我们只好选择先下载到本地再上传到服务器了。

  1. 换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/pytorch/
conda config --set show_channel_urls yes
  1. 建环境
conda create -n mink python=3.8
conda activate mink

坑三:要先安装pytorch再安装openblas-devel,而不是像官方这样,因为先安装openblas-devel,之后安装pytorch可能会报版本不兼容的错
在这里插入图片描述

  1. 安装pytorch

pytorch安装前先去官网找到合适的命令:https://pytorch.org/get-started/previous-versions/
在这里插入图片描述
不过这里注意不要加上最后的 -c pytorch,这意思是从pytorch官网下载,很慢!!!

conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=10.2
  1. 安装openblas-devel
conda install openblas-devel -c anaconda
  1. 安装MinkowskiEngine
cd  MinkowskiEngine
export CXX=g++-7
python setup.py install --blas_include_dirs=${CONDA_PREFIX}/include --blas=openblas

时间会比较久,耐心等待

  1. 测试安装是否成功
python
>>> import MinkowskiEngine as ME
>>> print(ME.__version__)

没有报错说明安装成功

猜你喜欢

转载自blog.csdn.net/weixin_43693967/article/details/123722994#comments_28551667