装库要记住三件事,官网+csdn+耐心。装库太慢就边看剧边装,不要影响心态。
首先上官网:
GitHub - NVIDIA/MinkowskiEngine: Minkowski Engine is an auto-diff neural network library for high-dimensional sparse tensors
上面的有pip,conda,system python 三种安装方式。
一般联网安装不了的,就选择本地安装,说白了这些库就是一堆代码,最终还是要下载到本地的。
这里minkwindow安装,选择conda(因为这里有本地下载,):
conda create -n py3-mink python=3.8
conda activate py3-mink
conda install openblas-devel -c anaconda
conda install pytorch=1.9.0 torchvision cudatoolkit=11.1 -c pytorch -c nvidia
# Install MinkowskiEngine
# Uncomment the following line to specify the cuda home. Make sure `$CUDA_HOME/nvcc --version` is 11.X
# export CUDA_HOME=/usr/local/cuda-11.1
pip install -U git+https://github.com/NVIDIA/MinkowskiEngine -v --no-deps --install-option="--blas_include_dirs=${CONDA_PREFIX}/include" --install-option="--blas=openblas"
# 这里不建议使用在线安装,希望尝试一下也可以
# Or if you want local MinkowskiEngine,建议使用这里的本地安装
git clone https://github.com/NVIDIA/MinkowskiEngine.git
cd MinkowskiEngine
python setup.py install --blas_include_dirs=${CONDA_PREFIX}/include --blas=openblas
嫌弃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
我的是cuda11.4
cuda版本查看命令:命令行输入nvidia-smi
如果本地安装是出现进程被kill,参考下面的论述:
如果是个人电脑,CPU核数不够多的,安装之前先把并行安装的thread数降低,否则会导致进程卡死:
即把setup.py文件内位于141行的MAX_COMPILATION_THREADS变量值从12改成4.
若是实验室服务器配置比较好的可以忽略此步骤。
安装成功后,我要做的这个项目出现以下问题:
AttributeError: type object 'MinkowskiEngineBackend._C.RegionType' has no attribute 'HYPERCUBE'
这种AttributeError,大概率是版本不匹配导致的。一般有两种方法:降版本或者改代码。这里选择改代码是简单而有效的,不信的可以去尝试降低版本。
降低版本一般有两种方法,第一种是pip insatll xxx=={指定的版本号},第二种是去github上找源码下载到本地。
这里会出现两个错误,
改代码是比较好的方式,虽然需要改变很多变量名。相比于MinkowskiEngine0.4.3的年久失修,加上我的服务器是RTX3090,这又牵扯到cuda和pytorch的版本问题。其中复杂实在难以叙述。目前已经解决的问题有:
一、由于MinkowskiEngine版本更新带来的一些变量名的改变。
二、RTX3090对应的cuda以及pytorch的版本问题。
查看torch支持的显卡算力,可以看到torch1.10.0+cu102不能支持sm_70以上的算力,而RTX的算力是sm_86,因此cu102是不行的,只能安装cu11版本的torch。
这里MinkowskiEngine0.5.4不太支持其他版本的torch,唯一成功的是torch1.9.0+cu102和torch1.9.0+cu111。由上文可知,最终选择了后者。
参考:
MinkowskiEngine 安装_dloading7的博客-CSDN博客
https://download.pytorch.org/whl/torch_stable.html
幸福的烦恼:显卡算力太高而pytorch版本太低不支持_cuda版本太高 pytorch不支持_是Yu欸的博客-CSDN博客