Skip to content
Chris Choy edited this page Jun 12, 2021 · 30 revisions

Installing the Minkowski Engine

v0.5

Currently, unavailable to the public.

From the Source

sudo apt install libopenblas-dev
pip install -U git+https://github.com/NVIDIA/MinkowskiEngine
# If it gives you "Unsupported GNU version!" use
# export CC=g++-7; pip install git+https://github.com/NVIDIA/MinkowskiEngine

Cloning the MinkowskiEngine git repo

sudo apt install libopenblas-dev
git clone https://github.com/NVIDIA/MinkowskiEngine
cd MinkowskiEngine
pip install -U ./
# If it gives you "Unsupported GNU version!" use
# export CC=g++-7; pip install -U ./

Build a Docker image with ME v0.5

  1. Install the NVIDIA Container Toolkit link
  2. By default, the NVIDIA Runtime is not available when running docker build. To mitigate this add "default-runtime": "nvidia" to the Docker configuration file /etc/docker/daemon.json.
{
    "runtimes": {
        "nvidia": {
            "path": "/usr/bin/nvidia-container-runtime",
            "runtimeArgs": []
         } 
    },
    "default-runtime": "nvidia" 
}

Make sure to restart the service after saving the file: sudo systemctl restart docker

  1. Create a Dockerfile in a project folder with the following content:
FROM nvidia/cuda:10.2-devel

# https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/user-guide.html#dockerfiles
# With these variables you don't have to run the final image with the --gpus argument.
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility

RUN apt update \
    && apt install -y python3.7 python3-pip git \
    && python3.7 -m pip install --upgrade --force pip

# Required by ME
RUN apt install -y libopenblas-dev python3.7-dev

# ME installation requires this.
RUN ln -s /usr/bin/python3.7 /usr/bin/python && ln -s /usr/bin/pip3 /usr/bin/pip

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

# Install pip requirements
ADD requirements.txt .
RUN python3.7 -m pip install torch
RUN export CXX=g++-7
RUN pip install git+https://github.com/NVIDIA/MinkowskiEngine.git@v0.5 --install-option="--blas=openblas"
RUN python3.7 -m pip install -r requirements.txt
  1. In the folder, build the image by running docker build -t me:latest .
  2. Start an interactive container by running: docker run -it --rm ws

Confirm that it worked by executing: python -c "import MinkowskiEngine as ME; print(ME.__version__)" and you should be greeted by the output 0.5.0b.

System Python

sudo apt install libopenblas-dev
pip install MinkowskiEngine

From the Source

sudo apt install libopenblas-dev
pip install -U git+https://github.com/NVIDIA/MinkowskiEngine
# If it gives you "Unsupported GNU version!" use
# export CXX=g++-7; pip install git+https://github.com/NVIDIA/MinkowskiEngine

Specifying the compiler

Use the environment variable CXX to control the compiler.

export CXX=g++-7; pip install git+https://github.com/StanfordVL/MinkowskiEngine

If you have multiple python versions and want to specify the version, define an environment variable to install the Minkowski Engine on the specified version.

export PYTHON=python3.7
$PYTHON setup.py install

MAX_JOBS

To specify the number of parallel compilation jobs, set the environment variable MAX_JOBS.

export MAX_JOBS=4; python setup.py install
export MAX_JOBS=4; pip install MinkowskiEngine

Installation options

# export CXX=g++-7; If you have an older version of GCC.
pip install -U git+https://github.com/StanfordVL/MinkowskiEngine \
                           \ # if you want to force cuda installation
                           --install-option="--force_cuda" \
                           \ # if you want to force no cuda installation. force_cuda supercedes cpu_only
                           --install-option="--cpu_only" \
                           \ # optional when torch fails to find cuda_home.
                           --install-option="--cuda_home=<cuda_home>" \
                           \ # override to openblas, atlas, mkl, blas
                           --install-option="--blas=<blas>" \
                           \ # blas include and library path if default ones fail
                           --install-option="--blas_include_dirs=<csv>" \
                           --install-option="--blas_library_dirs=<csv>"

With Anaconda

conda install mkl mkl-include -c intel
conda install pytorch -c pytorch
git clone https://github.com/StanfordVL/MinkowskiEngine.git
cd MinkowskiEngine
python setup.py install --blas=mkl

nvcc fatal : Unknown option -fopenmp

If you are using pytorch v1.5 or lower, you might experience the following error when compiling MinkowskiEngine v0.5. This is an error in the pytorch, which has been fixed on pytorch v1.6 https://github.com/pytorch/pytorch/pull/36945/files.

Please install pytorch v1.6.

error: Command "/usr/local/cuda/bin/nvcc -I/home/chrischoy/anaconda3/envs/py3-mink-reg/lib/python3.8/site-packages/torch/include -I/home/chrischoy/anaconda3/envs/py3-mink-reg/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/chrischoy/anaconda3/envs/py3-mink-reg/lib/python3.8/site-packages/tor
ch/include/TH -I/home/chrischoy/anaconda3/envs/py3-mink-reg/lib/python3.8/site-packages/torch/include/THC -I/usr/local/cuda/include -I/home/chrischoy/projects/MinkowskiEngine/src -I/home/chrischoy/projects/MinkowskiEngine/src/3rdparty -I/home/chrischoy/anaconda3/envs/py3-mink-reg/include/python3.8 -c /home/chrischoy
/projects/MinkowskiEngine/src/math_functions_cpu.cpp -o build/temp.linux-x86_64-3.8/home/chrischoy/projects/MinkowskiEngine/src/math_functions_cpu.o -fopenmp -O3 -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14" failed with exit status 1

nvcc fatal : Unsupported gpu architecture 'compute_86'

NVCC version you are using might be lower than NVCC used for pytorch. You can specify the CUDA_ARCH using the following command

export TORCH_CUDA_ARCH_LIST="5.2 6.0 6.1 7.0 7.5 8.0"; python setup.py install

Specifying CXX

/usr/local/cuda/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!

sudo apt install g++-7
export CXX=gcc-7; python setup.py install

Possible compilation error with torch 1.4

In a very rare case, you might get compilation errors

error: cannot call member function `void std::basic_string<_CharT, _Traints, _Alloc>::_Rep::_M_set_sharable() ....` without object

[2020-04-15] Got a report that using torch 1.3.1 solved the issue, but it is unclear what exactly caused the problem.

Compilation error with GCC < 7

error: invalid static_cast from type ‘const torch::OrderedDict<std::basic_string<char>, at::Tensor>’ to type ‘torch::OrderedDict<std::basic_string<char>, at::Tensor>&

To install g++ > 6, https://linuxize.com/post/how-to-install-gcc-compiler-on-ubuntu-18-04/

sudo apt install software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install g++-7

A related issue can be found at #124

basic_string error

    /usr/include/c++/7/bits/basic_string.tcc:1067:16: error: cannot call member function ‘void std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_M_set_sharable() [with _CharT = char16_t; _Traits = std::char_traits<char16_t>; _Alloc = std::allocator<char16_t>]’ without object
           __p->_M_set_sharable();

https://github.com/pytorch/vision/issues/1893

Upgrade CUDA version >= 10.1.243

With Docker

https://github.com/StanfordVL/MinkowskiEngine/issues/135 https://github.com/StanfordVL/MinkowskiEngine/issues/88